Example #1
0
        public int Update(Models.MVendor model)
        {
            Common.Logger l         = new Common.Logger();
            string        ClassName = "CVendor";

            try
            {
                var query = from o in obj.Vendors where Convert.ToString(o.id) == model.id select o;

                foreach (var item in query)
                {
                    item.name    = model.name;
                    item.Address = model.Addreess;
                    item.phone   = model.phone;
                }
                l.Print(ClassName, Common.LogPointer.Info.ToString(), "Model Values id[" + model.id + "] name[" + model.name + "] Adress[" + model.Addreess + "] phone[" + model.phone + "]");
                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);
            }
        }
Example #2
0
        public int Save(Models.MVendor model)
        {
            Common.Logger l         = new Common.Logger();
            string        ClassName = "CVendor";

            try
            {
                DB.Vendor bs = new DB.Vendor();
                bs.id          = Convert.ToInt32(model.id);
                bs.name        = model.name;
                bs.Address     = model.Addreess;
                bs.phone       = model.phone;
                bs.WareHouseId = Convert.ToInt32(model.WareHouseId);
                l.Print(ClassName, Common.LogPointer.Info.ToString(), "Model Values id[" + model.id + "] name[" + model.name + "] Address[" + model.Addreess + "] phone[" + model.phone + "]");
                obj.Vendors.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);
            }
        }
Example #3
0
        public List <Models.MVendor> GetAllbyid(int id)
        {
            List <Models.MVendor> model = new List <Models.MVendor>();
            var query = from o in obj.Vendors where o.id == id select o;

            foreach (var item in query)
            {
                Models.MVendor m = new Models.MVendor();
                m.id       = Convert.ToString(item.id);
                m.name     = item.name;
                m.Addreess = item.Address;
                m.phone    = item.phone;

                model.Add(m);
            }

            return(model);
        }
Example #4
0
        public List <Models.MVendor> GetAll()
        {
            List <Models.MVendor> model = new List <Models.MVendor>();
            var query = from o in obj.Vendors select o;

            foreach (var item in query)
            {
                Models.MVendor m = new Models.MVendor();
                m.id          = Convert.ToString(item.id);
                m.name        = item.name;
                m.Addreess    = item.Address;
                m.phone       = item.phone;
                m.WareHouseId = item.WareHouseId.ToString();
                model.Add(m);
            }

            return(model);
        }
Example #5
0
        protected void btnSave_Click1(object sender, EventArgs e)
        {
            string vendorID      = lblVendor.Text;
            string VendorName    = txtVendorname.Text;
            string VendorAddress = txtVendorAddress.Text;
            string VendorPhone   = txtVendorphone.Text;

            Models.MVendor mv = new Models.MVendor();
            mv.id       = Convert.ToString(vendorID);
            mv.name     = VendorName;
            mv.Addreess = VendorAddress;
            mv.phone    = VendorPhone;
            Classes.CVendor ccv = new Classes.CVendor();
            if (ccv.Update(mv) < 0)
            {
                ShowFailMessage();
            }
            else
            {
                ShowSuccessMessage();
                ClearTextBoxes(Page);
                BindData();
            }
        }
Example #6
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            if (Session["WareHouse"] != null)
            {
                string WareHouseId = Session["WareHouse"].ToString();

                if (Page.IsValid)
                {
                    string         VendorName    = txtVendorName.Text;
                    string         VendorAddress = txtVendorAddress.Text;
                    string         VendorPhone   = txtVendorPhoneNo.Text;
                    Models.MVendor mv            = new Models.MVendor();
                    mv.name        = VendorName;
                    mv.Addreess    = VendorAddress;
                    mv.phone       = VendorPhone;
                    mv.WareHouseId = WareHouseId;
                    Classes.CVendor ccv = new Classes.CVendor();
                    if (ccv.Save(mv) > 0)
                    {
                        //ShowFailMessage();
                        Classes.CCashAccount ca = new Classes.CCashAccount();
                        Models.MCashAccount  ma = new Models.MCashAccount();
                        ma.CashAccountName = VendorName;
                        ma.BeginDate       = DateTime.Now.ToShortDateString();
                        ma.ClientId        = -1;
                        ma.OpeningBalance  = "0";
                        ma.AccountType     = ma.AccountType = Common.Constants.CashAccountTypes.Vendor.ToString();
                        ma.VendorId        = ccv.GetLastVendorId();;
                        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[" + txtVendorName.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("Vendor Saved but Account was not opened");
                        }
                    }
                    else
                    {
                        ShowFailMessage();
                    }
                }
            }
            else
            {
                ShowErrorModal("Cannot Save, No Warehouse associated with current user");
            }
        }