protected void ddlCustomer_SelectedIndexChanged(object sender, EventArgs e) { if (Page.IsPostBack) { string ClientId = ddlCustomer.SelectedValue.ToString(); if (ClientId != "-1") { Classes.CClients cc = new Classes.CClients(); txtGrantorInfo.Text = cc.ReturnGrantorName(ClientId); } } }
private void BindPageControls() { Classes.CClients ccl = new Classes.CClients(); if (Session["WareHouse"] != null) { string WareHouseId = Session["WareHouse"].ToString(); List <Models.MClients> Clients = new List <Models.MClients>(); Clients = ccl.GetAll(); Clients = (from o in Clients where o.WareHouseId == WareHouseId select o).ToList(); grdClients.DataSource = Clients; grdClients.DataBind(); BindDropDown(); } }
private void BindClientsDdl() { Dictionary <int, string> Items = new Dictionary <int, string>(); List <Models.MClients> get = new List <Models.MClients>(); Classes.CClients cw = new Classes.CClients(); get = cw.GetAll(); Items.Add(-1, "Please select Clients"); for (int i = 0; i < get.Count; i++) { int id = get[i].id; string name = get[i].Name; Items.Add(Convert.ToInt32(id), name); } ddlClient.DataTextField = "Value"; ddlClient.DataValueField = "Key"; ddlClient.DataSource = Items; ddlClient.DataBind(); }
protected void btnSave_Click(object sender, EventArgs e) { if (Convert.ToInt32(ddlClientType.SelectedValue) > 0) { string ClientTypeId = ddlClientType.SelectedValue.ToString(); string ClientName = txtClientName.Text; string ClientPhone = txtPhone.Text; string ClientEmail = txtEmail.Text; string ClientAddress1 = txtAddress1.Text; string ClientAddress2 = txtAddress2.Text; string City = txtCity.Text; string eDate = DateTime.Now.ToString(); bool IsVendor = false; if (cbIsVendor.Checked) { IsVendor = true; } Models.MClients mc = new Models.MClients(); mc.id = Convert.ToInt32(lblClientId.Text); mc.ClientTypeld = ClientTypeId; mc.Name = ClientName; mc.phone = ClientPhone; mc.Address1 = ClientAddress1; mc.Address2 = ClientAddress2; mc.EmailAddress = ClientEmail; mc.City = City; mc.isVendor = IsVendor; mc.edate = eDate; Classes.CClients cc = new Classes.CClients(); if (cc.Update(mc) < 0) { ShowFailMessage(); } else { ShowSuccessMessage(); BindPageControls(); } } }
protected void btnSubmit_Click(object sender, EventArgs e) { if (Session["WareHouse"] != null) { string WareHouseId = Session["WareHouse"].ToString(); if (Convert.ToInt32(ddlClientType.SelectedValue) > 0) { string ClientTypeId = ddlClientType.SelectedValue.ToString(); string ClientName = txtClientName.Text; string ClientPhone = txtPhone.Text; string ClientEmail = txtEmail.Text; string ClientAddress1 = txtAddress1.Text; string ClientAddress2 = txtAddress2.Text; string City = txtCity.Text; string eDate = DateTime.Now.ToString(); bool IsVendor = false; if (cbIsVendor.Checked) { IsVendor = true; } Models.MClients mc = new Models.MClients(); mc.ClientTypeld = ClientTypeId; mc.Name = ClientName; mc.phone = ClientPhone; mc.Address1 = ClientAddress1; mc.Address2 = ClientAddress2; mc.EmailAddress = ClientEmail; mc.City = City; mc.isVendor = IsVendor; mc.edate = eDate; mc.WareHouseId = (WareHouseId); mc.GrantorName = txtGrantorName.Text; mc.NIC = txtNIC.Text; mc.GrantorNIC = txtGrantorNIC.Text; Classes.CClients cc = new Classes.CClients(); if (cc.Save(mc) > 0) { Classes.CCashAccount ca = new Classes.CCashAccount(); Models.MCashAccount ma = new Models.MCashAccount(); ma.CashAccountName = ClientName; ma.BeginDate = eDate; ma.ClientId = cc.GetLastClientId(); ma.OpeningBalance = "0"; ma.AccountType = Common.Constants.CashAccountTypes.Client.ToString(); ma.VendorId = -1; ma.WareHouseId = Convert.ToInt32(Session["WareHouse"].ToString()); if (ca.Save(ma) > 0) { Classes.CCashTransaction cct = new Classes.CCashTransaction(); Models.MCashTransactions mct = new Models.MCashTransactions(); mct.CashAccountId = ca.GetLastAccountId(); mct.Credit = "0"; mct.Debit = "0"; mct.Description = "Opened Client Account[" + txtClientName.Text + "]"; mct.eDate = DateTime.Now.ToShortDateString(); mct.FiscalYearId = Convert.ToInt32(Session["FiscalYear"].ToString()); mct.OrderId = -1; mct.Total = "0"; mct.TransactionId = -1; mct.TransactionType = "Credit"; mct.WareHouseId = Convert.ToInt32(Session["WareHouse"].ToString()); mct.UserId = Session["UserId"].ToString(); if (cct.Save(mct) > 0) { ShowSuccessMessage(); ClearTextBoxes(Page); } else { ShowFailMessage(); } } else { ShowErrorModal("Client Saved but Account was not opened"); } } else { ShowFailMessage(); } } } else { ShowErrorModal("Cannot Save, No Warehouse associated with current user"); } }