using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Text;
namespace WebApplication1
{
using Customerservice;
class program
{
public string printcustomerlist(Customer_Service service,List<Customer_Filter> filter)
{
StringBuilder sb=new StringBuilder();
sb.AppendLine("Printing Customer list");
Customer[] list = service.ReadMultiple(filter.ToArray(), null, 100);
foreach(Customer c in list)
{
sb.AppendLine(printcustomer(c));
}
return sb.ToString();
}
static string printcustomer(Customer c)
{
return "No:{"+c.No+"} Name:{"+c.Name+"} Bus.Pos.Group:{"+c.Gen_Bus_Posting_Group+"} Cust.Pos.Group: {"+c.Customer_Posting_Group+"}";
}
public void Createcustomer(string no,string name,Customer_Service service, string genbusposg, string Custposg)
{
Customer cust = new Customer();
cust.Name = name;
service.Create(ref cust);
cust.No = no;
cust.Gen_Bus_Posting_Group = genbusposg;
cust.Customer_Posting_Group = Custposg;
service.Update(ref cust);
}
public void deletecustomer(string no, Customer_Service service)
{
List<Customer_Filter> FilterArray = new List<Customer_Filter>();
Customer_Filter nofilter= new Customer_Filter();
nofilter.Field = Customer_Fields.No;
nofilter.Criteria = no;
FilterArray.Add(nofilter);
Customer[] custlist = service.ReadMultiple(FilterArray.ToArray(), null, 1);
service.Delete(custlist[0].Key);
}
public void Modifycustomer(string no,string name,Customer_Service service, string genbusposg, string Custposg)
{
List<Customer_Filter> FilterArray = new List<Customer_Filter>();
Customer_Filter nofilter = new Customer_Filter();
nofilter.Field = Customer_Fields.No;
nofilter.Criteria = no;
FilterArray.Add(nofilter);
Customer[] custlist = service.ReadMultiple(FilterArray.ToArray(), null, 1);
custlist[0].Name = name;
custlist[0].Gen_Bus_Posting_Group = genbusposg;
custlist[0].Customer_Posting_Group = Custposg;
service.Update(ref custlist[0]);
}
}
public partial class Service : System.Web.UI.Page
{
program a = new program();
Customer_Service service = new Customer_Service();
List<Customer_Filter> FilterArray = new List<Customer_Filter>();
protected void Page_Load(object sender, EventArgs e)
{
service.UseDefaultCredentials = true;
Customerbox.Text = a.printcustomerlist(service, FilterArray);
}
protected void Dcustbutton_Click(object sender, EventArgs e)
{
service.UseDefaultCredentials = true;
a.deletecustomer(CustNoBox.Text, service);
Customerbox.Text = a.printcustomerlist(service, FilterArray);
}
protected void Ccustbutton_Click(object sender, EventArgs e)
{
service.UseDefaultCredentials = true;
a.Createcustomer(CustNoBox.Text,CustnameBox.Text, service, CustomerGenBusPostingGroup.SelectedValue.ToString(), CustPostingGroup.SelectedValue.ToString());
Customerbox.Text = a.printcustomerlist(service, FilterArray);
}
protected void MCustbotton_Click(object sender, EventArgs e)
{
service.UseDefaultCredentials = true;
a.Modifycustomer(CustNoBox.Text,CustnameBox.Text, service, CustomerGenBusPostingGroup.SelectedValue.ToString(), CustPostingGroup.SelectedValue.ToString());
Customerbox.Text = a.printcustomerlist(service, FilterArray);
}
}
}