コード例 #1
0
ファイル: CClients.cs プロジェクト: centhacker/RetailSystem
        public int Delete(Models.MClients model)
        {
            Common.Logger l         = new Common.Logger();
            string        ClassName = "CClients";

            try
            {
                var query = from o in obj.Clients where o.id == model.id select o;
                foreach (var item in query)
                {
                    obj.Clients.DeleteOnSubmit(item);
                }
                l.Print(ClassName, Common.LogPointer.Info.ToString(), "Model id[" + model.id + "] ClientTypeId[" + model.ClientTypeld + "] Name[" + model.Name + "] phone[" + model.phone + "] EmailAddress[ " + model.EmailAddress + "] Address1 [" + model.Address1 + "] Address2 [" + model.Address2 + "] City [" + model.City + "] isVendor[ " + model.isVendor + "] eDate[ " + model.edate + "]");
                obj.SubmitChanges();
                l.Print(ClassName, Common.LogPointer.Info.ToString(), "Record Deleted Successfully");
                return(1);
            }


            catch (Exception ex)
            {
                l.Print(ClassName, Common.LogPointer.Error.ToString(), ex.ToString());
                return(-1);
            }
        }
コード例 #2
0
ファイル: CClients.cs プロジェクト: centhacker/RetailSystem
        public int Update(Models.MClients model)
        {
            Common.Logger l         = new Common.Logger();
            string        ClassName = "CClients";

            try
            {
                var query = from o in obj.Clients where o.id == model.id select o;

                foreach (var item in query)
                {
                    item.ClientTypeId = int.Parse(model.ClientTypeld);
                    item.Name         = model.Name;
                    item.EmailAddress = model.EmailAddress;
                    item.Address1     = model.EmailAddress;
                    item.Address2     = model.Address2;
                    item.City         = model.City;
                    item.isVendor     = model.isVendor;
                    item.eDate        = Convert.ToDateTime(model.edate);
                }
                l.Print(ClassName, Common.LogPointer.Info.ToString(), "Model id[" + model.id + "] ClientTypeId[" + model.ClientTypeld + "] Name[" + model.Name + "] phone[" + model.phone + "] EmailAddress[ " + model.EmailAddress + "] Address1 [" + model.Address1 + "] Address2 [" + model.Address2 + "] City [" + model.City + "] isVendor[ " + model.isVendor + "] eDate[ " + model.edate + "]");
                obj.SubmitChanges();
                l.Print(ClassName, Common.LogPointer.Info.ToString(), "Record Updated Successfully");
                return(1);
            }
            catch (Exception ex)
            {
                l.Print(ClassName, Common.LogPointer.Error.ToString(), ex.ToString());
                return(-1);
            }
        }
コード例 #3
0
ファイル: CClients.cs プロジェクト: centhacker/RetailSystem
        public int Save(Models.MClients model)
        {
            Common.Logger l         = new Common.Logger();
            string        ClassName = "CClients";

            try
            {
                DB.Client bs = new DB.Client();
                bs.id           = Convert.ToInt32(model.id);
                bs.ClientTypeId = Convert.ToInt32(model.ClientTypeld);
                bs.Name         = model.Name;
                bs.phone        = model.phone;
                bs.EmailAddress = model.EmailAddress;
                bs.Address1     = model.Address1;
                bs.Address2     = model.Address2;
                bs.City         = model.City;
                bs.isVendor     = model.isVendor;
                bs.eDate        = Convert.ToDateTime(model.edate);
                bs.WareHouseId  = Convert.ToInt32(model.WareHouseId);
                bs.NIC          = model.NIC;
                bs.GrantorName  = model.GrantorName;
                bs.GrantorNIC   = model.GrantorNIC;
                l.Print(ClassName, Common.LogPointer.Info.ToString(), "Model id[" + model.id + "] ClientTypeId[" + model.ClientTypeld + "] Name[" + model.Name + "] phone[" + model.phone + "] EmailAddress[ " + model.EmailAddress + "] Address1 [" + model.Address1 + "] Address2 [" + model.Address2 + "] City [" + model.City + "] isVendor[ " + model.isVendor + "] eDate[ " + model.edate + "]");
                obj.Clients.InsertOnSubmit(bs);
                obj.SubmitChanges();
                l.Print(ClassName, Common.LogPointer.Info.ToString(), "Record Inserted Successfully");
                return(1);
            }
            catch (Exception ex)
            {
                l.Print(ClassName, Common.LogPointer.Error.ToString(), ex.ToString());
                return(-1);
            }
        }
コード例 #4
0
ファイル: CClients.cs プロジェクト: centhacker/RetailSystem
        public List <Models.MClients> GetAll()
        {
            List <Models.MClients> model = new List <Models.MClients>();
            var query = from o in obj.Clients select o;

            foreach (var item in query)
            {
                Models.MClients m = new Models.MClients();

                m.Name         = item.Name;
                m.isVendor     = Convert.ToBoolean(item.isVendor);
                m.Address1     = item.Address1;
                m.Address2     = item.Address2;
                m.EmailAddress = item.EmailAddress;
                m.id           = item.id;
                m.phone        = item.phone;
                m.City         = item.City;
                m.ClientTypeld = (from a in obj.ClientTypes where a.id == item.ClientTypeId select a.Name).FirstOrDefault().ToString();
                m.WareHouseId  = item.WareHouseId.ToString();
                m.NIC          = item.NIC;
                m.GrantorName  = item.GrantorName;
                m.GrantorNIC   = item.GrantorNIC;
                model.Add(m);
            }

            return(model);
        }
コード例 #5
0
 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();
         }
     }
 }
コード例 #6
0
 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");
     }
 }