protected void imgbtnDelete_Click(object sender, ImageClickEventArgs e)
 {
     try
     {
         ImageButton imb = new ImageButton();
         imb = (ImageButton)sender;
         if (imb != null)
         {
             Int32           ID = ToInt32(imb.CommandArgument);
             TransSaleHeader o  = new TransSaleHeader();
             using (BillingEntities cre = new BillingEntities())
             {
                 o = cre.TransSaleHeaders.FirstOrDefault(w => w.SaleHeaderID.Equals(ID));
                 if (o != null)
                 {
                     cre.TransSaleHeaders.Remove(o);
                     cre.SaveChanges();
                 }
             };
         }
         ShowMessageBox("ลบรายการสำเร็จ.");
         BindData();
     }
     catch (Exception ex)
     {
     }
 }
Beispiel #2
0
        protected void btnModalSave_Click(object sender, EventArgs e)
        {
            try
            {
                //Validate
                if (txtMUnitCode.Text == "")
                {
                    ShowMessageBox("กรุณาระบุ ชื่อลูกค้า !!!");
                    ModalPopupExtender1.Show();
                    return;
                }

                if (txtMUnitName.Text == "")
                {
                    ShowMessageBox("กรุณาระบุ รหัส !!!");
                    ModalPopupExtender1.Show();
                    return;
                }

                MasUnit o = new MasUnit();
                if (hddMode.Value == "Add") // Add
                {
                    o             = new MasUnit();
                    o.UnitCode    = txtMUnitCode.Text;
                    o.UnitName    = txtMUnitName.Text;
                    o.Active      = "Y";
                    o.CreatedBy   = GetUsername();
                    o.CreatedDate = DateTime.Now;
                    using (BillingEntities cre = new BillingEntities())
                    {
                        cre.MasUnits.Add(o);
                        cre.SaveChanges();
                    };
                }
                else //Edit
                {
                    int objID = ToInt32(hddID.Value);
                    using (BillingEntities cre = new BillingEntities())
                    {
                        o = cre.MasUnits.FirstOrDefault(w => w.UnitID.Equals(objID));
                        if (o != null)
                        {
                            o.UnitCode    = txtMUnitCode.Text;
                            o.UnitName    = txtMUnitName.Text;
                            o.UpdatedBy   = GetUsername();
                            o.UpdatedDate = DateTime.Now;
                        }
                        cre.SaveChanges();
                    };
                }

                BindData();
                ShowMessageBox("บันทึกข้อมูลสำเร็จ.");
            }
            catch (Exception ex)
            {
                ShowMessageBox("เกิดข้อผิดพลาด กรุณาติดต่อผู้ดูแลระบบ.");
                SendMailError(ex.Message, System.Reflection.MethodBase.GetCurrentMethod());
            }
        }
Beispiel #3
0
        // *************************************************************************************************
        // Process report for selected client for specific billdate
        // *************************************************************************************************
        public void createBill(int cltID, DateTime?billDate)
        {
            // get list of reports to run for Client
            BillingEntities cltBilling    = new BillingEntities();
            string          rptBillPeriod = billDate.Value.ToString("MM");
            DateTime?       rptBillDate   = billDate;
            string          rptBillMonth  = rptBillDate.Value.ToString("MM");
            string          rptBillYear   = rptBillDate.Value.Year.ToString();
            var             rptList       = (from c in cltBilling.BillDeliveries where c.CltID == cltID && c.Active == true select c).ToList <BillDelivery>();

            if (rptList != null)
            {
                foreach (var rpt in rptList)
                {
                    GetRptData(cltID, rptBillMonth, rptBillYear, rpt.ID);
                }
            }
            // get list of master reports to run for current day
            var masterList = (from m in cltBilling.BillDeliveries where m.CltID == cltID && m.Active == true && m.ReportGroup == "Master" select m).ToList <BillDelivery>();

            if (masterList != null)
            {
                foreach (var mlst in masterList)
                {
                    GetRptData(mlst.CltID.Value, rptBillMonth, rptBillYear, mlst.ID);
                }
            }
        }
Beispiel #4
0
        protected void BindData()
        {
            try
            {
                List <MasUnit> lst  = new List <MasUnit>();
                string         Name = txtUnitName.Text;
                string         Code = txtUnitCode.Text;
                using (BillingEntities cre = new BillingEntities()){
                    lst = cre.MasUnits.Where(w => w.UnitCode.Contains(Code) &&
                                             w.UnitName.Contains(Name)).ToList();
                };

                if (lst != null && lst.Count > 0)
                {
                    gv.DataSource = lst;
                }
                else
                {
                    gv.DataSource = null;
                }

                gv.DataBind();
            }
            catch (Exception ex)
            {
                SendMailError(ex.Message, System.Reflection.MethodBase.GetCurrentMethod());
            }
        }
        protected void BindDDL()
        {
            try
            {
                List <MasSender> lst = new List <MasSender>();
                using (BillingEntities cre = new BillingEntities())
                {
                    lst = cre.MasSenders.ToList();
                };

                if (lst != null && lst.Count > 0)
                {
                    ddlSender.DataSource         = lst;
                    ddlSender.DataValueField     = "SenderID";
                    ddlSender.DataTextField      = "SenderName";
                    Session["ReportSaleDeliDDL"] = lst;
                }
                else
                {
                    ddlSender.DataSource         = null;
                    Session["ReportSaleDeliDDL"] = null;
                }

                ddlSender.DataBind();
            }
            catch (Exception ex)
            {
            }
        }
Beispiel #6
0
        protected void btnLogin_Click(object sender, EventArgs e)
        {
            if (txtUser.Text == "")
            {
                lbMsg.Text = "กรุณาระบุ Username !!!";
                return;
            }

            if (txtPass.Text == "")
            {
                lbMsg.Text = "กรุณาระบุ Password !!!";
                return;
            }

            MasUserLogin o = new MasUserLogin();

            Session["Username"] = txtUser.Text;
            using (BillingEntities cre = new BillingEntities())
            {
                o = cre.MasUserLogins.FirstOrDefault(w => w.Username.Equals(txtUser.Text) && w.Password.Equals(txtPass.Text));
                if (o != null && o.Active == "Y")
                {
                    Session["Username"] = o.Username;
                    o.LastLogin         = DateTime.Now;
                    cre.SaveChanges();
                }
                else
                {
                    lbMsg.Text = "Username, Password ไม่ถูกต้อง !!!";
                    return;
                }
            };

            Response.Redirect("/Default.aspx");
        }
Beispiel #7
0
        public ActionResult RegisterParty(PartyVM vmObject)
        {
            BillingEntities entity   = new BillingEntities();
            Party           modelObj = new Party();

            modelObj.Name        = vmObject.Name;
            modelObj.Address     = vmObject.Address;
            modelObj.MobileNo    = vmObject.MobileNo;
            modelObj.CompanyName = vmObject.CompanyName;
            modelObj.GSTN_Number = vmObject.GSTN_Number;
            modelObj.PanNo       = vmObject.PanNo;
            //modelObj.Registered = vmObject.Registered.Sele ;
            modelObj.Registered = "Registered";
            var val = Request.Form["Registered"];

            //if(ModelState.IsValid)
            //{
            entity.RegisterParty(modelObj.Name, modelObj.CompanyName, modelObj.Address, modelObj.MobileNo, modelObj.GSTN_Number, modelObj.PanNo);
            //}
            //else
            //{
            //    return View("RegisterParty");
            //}
            return(View("Success"));
        }
Beispiel #8
0
 protected void imgbtnDelete_Click(object sender, ImageClickEventArgs e)
 {
     try
     {
         ImageButton imb = (ImageButton)sender;
         if (imb != null)
         {
             MasUnit obj   = new MasUnit();
             int     objID = ToInt32(imb.CommandArgument);
             using (BillingEntities cre = new BillingEntities())
             {
                 obj = cre.MasUnits.FirstOrDefault(w => w.UnitID.Equals(objID));
                 if (obj != null)
                 {
                     obj.Active      = "N";
                     obj.UpdatedBy   = GetUsername();
                     obj.UpdatedDate = DateTime.Now;
                 }
                 //cre.MasUnits.Remove(obj);
                 cre.SaveChanges();
             };
             BindData();
         }
         else
         {
             SendMailError("imb is null", System.Reflection.MethodBase.GetCurrentMethod());
         }
     }
     catch (Exception ex)
     {
         ShowMessageBox("เกิดข้อผิดพลาด กรุณาติดต่อผู้ดูแลระบบ.");
         SendMailError(ex.Message, System.Reflection.MethodBase.GetCurrentMethod());
     }
 }
Beispiel #9
0
        protected void BindDDL()
        {
            try
            {
                DataTable dt = new DataTable();
                dt.Columns.Add("Text");
                dt.Columns.Add("Val");
                DataRow dr;

                #region Month
                DateTimeFormatInfo monthsInfo = DateTimeFormatInfo.GetInstance(null);
                for (int i = 1; i < 13; i++)
                {
                    dr         = dt.NewRow();
                    dr["Text"] = monthsInfo.GetMonthName(i);
                    dr["Val"]  = i.ToString();
                    dt.Rows.Add(dr);
                }
                if (dt != null && dt.Rows.Count > 0)
                {
                    ddlMonth.DataSource     = dt;
                    ddlMonth.DataTextField  = "Text";
                    ddlMonth.DataValueField = "Val";
                }
                else
                {
                    ddlMonth.DataSource = null;
                }

                ddlMonth.DataBind();
                ddlMonth.SelectedIndex = ddlMonth.Items.IndexOf(ddlMonth.Items.FindByValue(DateTime.Now.Month.ToString())); //ToInt32(obj.PayType);

                #endregion

                #region Year
                List <Int32> lstYear = new List <Int32>();
                using (BillingEntities cre = new BillingEntities())
                {
                    lstYear = cre.TransSaleHeaders.Select(s => s.ReceivedDate.HasValue ? s.ReceivedDate.Value.Year : 0).Distinct().OrderByDescending(od => od).ToList();
                }
                if (lstYear != null)
                {
                    ddlYear.DataSource    = lstYear;
                    ddlYear.SelectedIndex = ddlYear.Items.IndexOf(ddlYear.Items.FindByValue(DateTime.Now.Year.ToString())); //ToInt32(obj.PayType);
                }
                else
                {
                    ddlYear.DataSource = null;
                }

                ddlYear.DataBind();
                #endregion
            }
            catch (Exception ex)
            {
                SendMailError(ex.Message, System.Reflection.MethodBase.GetCurrentMethod());
            }
        }
        public ActionResult Delete(int id)
        {
            BillingEntities db      = new BillingEntities();
            var             getdata = db.Bills.FirstOrDefault(m => m.B_no == id);

            db.Bills.Remove(getdata);
            db.SaveChanges();
            return(RedirectToAction("Display", "Home"));
        }
Beispiel #11
0
        // *************************************************************************************************
        // ****  This will get the last bill date for client                            ****
        // *************************************************************************************************
        private DateTime?GetBillDate(int rptcltID)
        {
            BillingEntities billRptDate     = new BillingEntities();
            var             rptBillDateInfo = (from x in billRptDate.BillingLogs
                                               where x.CltID == rptcltID
                                               orderby x.BatchID descending
                                               select x.BillDate).FirstOrDefault();

            return(rptBillDateInfo);
        }
        protected void BindData()
        {
            try
            {
                List <ReportSaleDTO> lst      = new List <ReportSaleDTO>();
                DateTime             dateFrom = string.IsNullOrEmpty(txtDateFrom.Text) ? DateTime.MinValue : DateTime.ParseExact(txtDateFrom.Text, "dd/MM/yyyy", new System.Globalization.CultureInfo("en-US"));
                DateTime             dateTo   = string.IsNullOrEmpty(txtDateTo.Text) ? DateTime.MaxValue : DateTime.ParseExact(txtDateTo.Text, "dd/MM/yyyy", new System.Globalization.CultureInfo("en-US")).AddDays(1);
                string SaleNo = txtSaleNo.Text;
                string Serial = txtSn.Text;

                using (BillingEntities cre = new BillingEntities())
                {
                    lst = (from h in cre.TransSaleHeaders
                           join d in cre.TransSaleDetails on h.SaleHeaderID equals d.SaleHeaderID
                           join i in cre.MasItems on d.ItemID equals i.ItemID
                           where h.ReceivedDate >= dateFrom && h.ReceivedDate < dateTo
                           //date == DateTime.MinValue ? true : h.ReceivedDate.HasValue ? h.ReceivedDate.Value == date : true
                           select new ReportSaleDTO()
                    {
                        HeaderID = h.SaleHeaderID,
                        DetailID = d.SaleDetailID,
                        Tel = h.Tel,
                        CustomerName = h.DeliveryName,
                        Address = h.DeliverCountry + " " + h.DeliverProvince,
                        District = h.DeliverDistrict,
                        Country = h.DeliverCountry,
                        Province = h.DeliverProvince,
                        PostalCode = h.DeliverPostalCode,
                        SaleNumber = h.SaleNumber,
                        ItemCode = i.ItemCode,
                        ItemName = i.ItemName,
                        WarrantyDate = h.WarrantyDate,
                        SerialNumber = d.SerialNumber,
                    }).OrderBy(od => od.HeaderID).ToList();
                };

                if (lst != null && lst.Count > 0)
                {
                    //lstMod = ModDataFromSale(lst);
                    gv.DataSource             = lst;
                    Session["ReportWarranty"] = lst;
                }
                else
                {
                    gv.DataSource = null;
                }

                gv.DataBind();
            }
            catch (Exception ex)
            {
                SendMailError(ex.Message, System.Reflection.MethodBase.GetCurrentMethod());
            }
        }
        public ActionResult Update(int ID)
        {
            BillingEntities db = new BillingEntities();
            BillModel       dt = new BillModel();

            var getdata = db.Bills.FirstOrDefault(m => m.B_no == ID);

            dt.Product = getdata.Product;
            dt.Price   = getdata.Price;
            dt.Date    = (DateTime)getdata.Date;

            return(View(dt));
        }
Beispiel #14
0
        protected void SearchItem()
        {
            try
            {
                string            ItemCode = txtSearchItemCode.Text.ToLower();
                string            ItemName = txtSearchItemName.Text.ToLower();
                List <MasItemDTO> lst      = new List <MasItemDTO>();
                using (BillingEntities cre = new BillingEntities())
                {
                    //lst = (from i in cre.MasItems
                    //       join d in cre.Inventories on i.ItemID equals d.ItemID
                    //       where i.Active.Equals("Y") && d.Amount > 0
                    //       select new MasItemDTO()
                    //       {emName,
                    //           ItemCode = i.I
                    //           ItemID = i.ItemID,
                    //           ItemName = i.IttemCode,
                    //           ItemDesc = i.ItemDesc,
                    //           ItemPrice = i.ItemPrice.HasValue ? i.ItemPrice.Value : 0,
                    //           Amount = d.Amount,
                    //       }).ToList();

                    if (lst != null)
                    {
                        if (!string.IsNullOrEmpty(ItemCode))
                        {
                            lst = lst.Where(w => w.ItemCode.ToLower().Contains(ItemCode)).ToList();
                        }

                        if (!string.IsNullOrEmpty(ItemName))
                        {
                            lst = lst.Where(w => w.ItemName.ToLower().Contains(ItemName)).ToList();
                        }

                        lst = lst.OrderBy(od => od.ItemID).ToList();
                        gvItemSearch.DataSource = lst;
                        gvItemSearch.DataBind();
                    }
                    else
                    {
                        gvItemSearch.DataSource = null;
                        gvItemSearch.DataBind();
                    }
                };
            }
            catch (Exception ex)
            {
                gvItemSearch.DataSource = null;
                gvItemSearch.DataBind();
            }
        }
Beispiel #15
0
        protected void BindData()
        {
            try
            {
                if (string.IsNullOrEmpty(txtDateFrom.Text) || string.IsNullOrEmpty(txtDateTo.Text))
                {
                    ShowMessageBox("กรุณาระบุวันที่ที่ต้องการค้นหา. !!!");
                    return;
                }
                List <InventoryDTO> lst = new List <InventoryDTO>();
                string   Code           = txtItemCode.Text;
                string   Name           = txtItemName.Text;
                DateTime dateFrom       = string.IsNullOrEmpty(txtDateFrom.Text) ? DateTime.MinValue : DateTime.ParseExact(txtDateFrom.Text, "dd/MM/yyyy", new System.Globalization.CultureInfo("en-US"));
                DateTime dateTo         = string.IsNullOrEmpty(txtDateTo.Text) ? DateTime.MaxValue : DateTime.ParseExact(txtDateTo.Text, "dd/MM/yyyy", new System.Globalization.CultureInfo("en-US")).AddDays(1);
                using (BillingEntities cre = new BillingEntities())
                {
                    //lst = cre.Inventories.Where(w => w.Amount > 0).ToList();
                    //lst = (from l in cre.InventoryLogs
                    //       join i in cre.Inventories on l.InventoryID equals i.InventoryID
                    //       join m in cre.MasItems on i.ItemID equals m.ItemID
                    //       where l.Amount > 0
                    //       && (l.Action.Equals("Inbound") || l.Action.Equals("Outbound"))
                    //       && l.UpdatedDate >= dateFrom && l.UpdatedDate < dateTo
                    //       select new InventoryDTO()
                    //       {
                    //           InventoryID = l.InventoryID,
                    //           ItemID = m.ItemID,
                    //           ItemCode = m.ItemCode,
                    //           ItemName = m.ItemName,
                    //           Amount = l.Amount.HasValue ? l.Amount.Value : 0,
                    //           UpdatedDate = l.UpdatedDate.HasValue ? l.UpdatedDate.Value : DateTime.Now,
                    //           UpdatedBy = l.UpdatedBy,
                    //       }).OrderByDescending(od => od.UpdatedDate).ThenBy(od => od.ItemCode).ToList();
                };

                if (lst != null && lst.Count > 0)
                {
                    gv.DataSource = lst;
                }
                else
                {
                    gv.DataSource = null;
                }

                gv.DataBind();
            }
            catch (Exception ex)
            {
            }
        }
        public ActionResult Insert(BillModel d)
        {
            BillingEntities db = new BillingEntities();
            Bill            B  = new Bill();

            B.Product = d.Product;
            B.Price   = d.Price;
            B.Date    = d.Date;
            db.Bills.Add(B);
            db.SaveChanges();
            ViewBag.Text = "Details Inserted";

            return(RedirectToAction("Display", "Home"));
        }
        public ActionResult Update(int ID, BillModel dt)
        {
            BillingEntities db = new BillingEntities();

            var getdata = db.Bills.FirstOrDefault(m => m.B_no == ID);

            getdata.Product = (string)dt.Product;
            getdata.Price   = (Decimal)dt.Price;
            getdata.Date    = (DateTime)dt.Date;
            db.SaveChanges();

            ViewBag.Text = "Details Updated";


            return(RedirectToAction("Display", "Home"));
        }
        protected void LoginUser_LoggedIn(object sender, EventArgs e)
        {
            var loginForm = (System.Web.UI.WebControls.Login)sender;
            BillingEntities db = new BillingEntities();
            User user = db.Users.FirstOrDefault(s => s.Login.ToLower() == loginForm.UserName.ToLower());
            if (user == null) return;

            db.UsersLogs.AddObject(new UsersLog
                                       {
                                           Date = DateTime.Now,
                                           Text = "User logged in from Ip " + Request.UserHostAddress,
                                           UserId = user.Id
                                       });
            //user.IpAddress = Request.UserHostAddress;

            db.SaveChanges();
        }
Beispiel #19
0
        protected void imgbtnView_Click(object sender, ImageClickEventArgs e)
        {
            try
            {
                ModalPopupExtender1.Show();
                ImageButton imb      = new ImageButton();
                DateTime    dateFrom = string.IsNullOrEmpty(txtDateFrom.Text) ? DateTime.MinValue : DateTime.ParseExact(txtDateFrom.Text, "dd/MM/yyyy", new System.Globalization.CultureInfo("en-US"));
                DateTime    dateTo   = string.IsNullOrEmpty(txtDateTo.Text) ? DateTime.MaxValue : DateTime.ParseExact(txtDateTo.Text + " 235959", "dd/MM/yyyy HHmmss", new System.Globalization.CultureInfo("en-US"));
                string      ItemCode = "";
                imb = (ImageButton)sender;
                List <ReportSaleItemDTO> lst = new List <ReportSaleItemDTO>();
                if (imb != null)
                {
                    ItemCode = imb.CommandArgument;

                    using (BillingEntities cre = new BillingEntities())
                    {
                        lst = (from d in cre.GetReportSaleItemItemCode(dateFrom, dateTo, ItemCode)
                               select new ReportSaleItemDTO()
                        {
                            SaleHeaderID = d.SaleHeaderID,
                            SaleNumber = d.SaleNumber,
                            ItemCode = d.ItemCode,
                        }).OrderBy(od => od.ItemCode).ToList();
                    }

                    if (lst != null && lst.Count > 0)
                    {
                        //ModData(lst);
                        gvSale.DataSource = lst;
                    }
                    else
                    {
                        gvSale.DataSource = null;
                    }

                    gvSale.DataBind();
                }
            }
            catch (Exception ex)
            {
            }
        }
        public ActionResult Display()
        {
            BillingEntities  db  = new BillingEntities();
            DataModel        dt  = new DataModel();
            var              get = db.Bills.ToList();
            List <BillModel> lst = new List <BillModel>();

            foreach (var item in get)
            {
                lst.Add(new BillModel
                {
                    B_no    = item.B_no,
                    Product = item.Product,
                    Price   = (int)item.Price,
                    Date    = (DateTime)item.Date
                });
            }
            dt.list = lst;
            return(View(dt));
        }
Beispiel #21
0
        protected void imgbtnEdit_Click(object sender, ImageClickEventArgs e)
        {
            try
            {
                ImageButton imb = (ImageButton)sender;
                MasItem     obj = new MasItem();
                if (imb != null)
                {
                    int objID = ToInt32(imb.CommandArgument);
                    using (BillingEntities cre = new BillingEntities())
                    {
                        obj = cre.MasItems.FirstOrDefault(w => w.ItemID.Equals(objID));
                    };

                    if (obj != null)
                    {
                        hddID.Value   = imb.CommandArgument;
                        txtMCode.Text = obj.ItemCode;
                        txtMName.Text = obj.ItemName;
                        txtMDesc.Text = obj.ItemDesc;
                        //txtMPrice.Text = obj.ItemPrice.HasValue ? obj.ItemPrice.Value.ToString("###,##0") : "0";
                        txtMPrice.Text = obj.ItemPrice.HasValue ? obj.ItemPrice.Value.ToString("###,##0") : "0";
                        ModalPopupExtender1.Show();
                        hddMode.Value = "Edit";
                    }
                    else
                    {
                        SendMailError("obj is null, objID = " + imb.CommandArgument, System.Reflection.MethodBase.GetCurrentMethod());
                    }
                }
                else
                {
                    SendMailError("imb is null", System.Reflection.MethodBase.GetCurrentMethod());
                }
            }
            catch (Exception ex)
            {
                ShowMessageBox("เกิดข้อผิดพลาด กรุณาติดต่อผู้ดูแลระบบ.");
                SendMailError(ex.Message, System.Reflection.MethodBase.GetCurrentMethod());
            }
        }
Beispiel #22
0
        protected void imgbtnEdit_Click(object sender, ImageClickEventArgs e)
        {
            try
            {
                ImageButton  imb = (ImageButton)sender;
                MasUserLogin obj = new MasUserLogin();
                if (imb != null)
                {
                    using (BillingEntities cre = new BillingEntities())
                    {
                        obj = cre.MasUserLogins.FirstOrDefault(w => w.Username.Equals(imb.CommandArgument));
                    };

                    if (obj != null)
                    {
                        txtMUsername.Text = obj.Username;
                        chkActive.Checked = obj.Active == "Y" ? true : false;

                        ModalPopupExtender1.Show();
                        hddMode.Value = "Edit";
                    }
                    else
                    {
                        SendMailError("obj is null, objID = " + imb.CommandArgument, System.Reflection.MethodBase.GetCurrentMethod());
                    }
                }
                else
                {
                    SendMailError("imb is null", System.Reflection.MethodBase.GetCurrentMethod());
                }
            }
            catch (Exception ex)
            {
                ShowMessageBox("เกิดข้อผิดพลาด กรุณาติดต่อผู้ดูแลระบบ.");
                SendMailError(ex.Message, System.Reflection.MethodBase.GetCurrentMethod());
            }
        }
Beispiel #23
0
        // *************************************************************************************************
        // ****  This process will get a list of all reports to process for current date            ****
        // *************************************************************************************************
        public void createBill()
        {
            // get list of special reports to run for current day
            BillingEntities rptBilling    = new BillingEntities();
            string          rptBillPeriod = DateTime.Now.ToString("dd");
            var             cltList       = (from c in rptBilling.BillDeliveries where c.BillPeriod == rptBillPeriod && c.Active == true select c).ToList <BillDelivery>();

            if (cltList != null)
            {
                foreach (var clt in cltList)
                {
                    //DateTime? rptBillDate = GetBillDate(clt.CltID.Value);
                    DateTime?rptBillDate = DateTime.Now;
                    if (clt.Current == "Ahead")
                    {
                        rptBillDate = DateTime.Now.AddMonths(1);
                    }
                    string rptBillMonth = rptBillDate.Value.ToString("MM");
                    string rptBillYear  = rptBillDate.Value.Year.ToString();
                    GetRptData(clt.CltID.Value, rptBillMonth, rptBillYear, clt.ID);
                }
            }
            // get list of master reports to run for current day
            var masterList = (from m in rptBilling.BillDeliveries where m.BillPeriod == rptBillPeriod && m.Active == true && m.ReportGroup == "Master" select m).ToList <BillDelivery>();

            if (masterList != null)
            {
                foreach (var mlst in masterList)
                {
                    //DateTime? rptBillDate = GetBillDate(mlst.CltID.Value);
                    DateTime?rptBillDate  = DateTime.Now;
                    string   rptBillMonth = rptBillDate.Value.ToString("MM");
                    string   rptBillYear  = rptBillDate.Value.Year.ToString();
                    GetRptData(mlst.CltID.Value, rptBillMonth, rptBillYear, mlst.ID);
                }
            }
        }
 public override string[] GetRolesForUser(string username)
 {
     BillingEntities db=new BillingEntities();
     User user = db.Users.FirstOrDefault(s => s.Login == username);
     return user!=null && user.IsAdmin ? new string[] {"Admin"} : new string[0];
 }
 public override bool ValidateUser(string username, string password)
 {
     BillingEntities db=new BillingEntities();
     User user = db.Users.FirstOrDefault(s => s.Login == username);
     return (user != null) && (user.Password == password);
 }
Beispiel #26
0
 public EquipmentRepository(BillingEntities context)
     : base(context)
 {
     AutoSave = true;
 }
 public FacilityRepository(BillingEntities context)
     : base(context)
 {
     AutoSave = true;
     _context = context;
 }
Beispiel #28
0
        protected void BindData()
        {
            try
            {
                List <ReportSaleItemDTO> lst = new List <ReportSaleItemDTO>();
                DateTime dateFrom            = string.IsNullOrEmpty(txtDateFrom.Text) ? DateTime.MinValue : DateTime.ParseExact(txtDateFrom.Text, "dd/MM/yyyy", new System.Globalization.CultureInfo("en-US"));
                DateTime dateTo = string.IsNullOrEmpty(txtDateTo.Text) ? DateTime.MaxValue : DateTime.ParseExact(txtDateTo.Text + " 235959", "dd/MM/yyyy HHmmss", new System.Globalization.CultureInfo("en-US"));
                //Int32 itemID = ToInt32(ddlMItem.SelectedItem.Value);
                string ItemCode = "", Group = "";
                //ItemCode = ddlItem.SelectedItem.Value;
                ItemCode = txtItemCode.Text;
                Group    = chkShow.Checked ? "1" : "";

                using (BillingEntities cre = new BillingEntities())
                {
                    lst = (from d in cre.GetReportSaleItem(dateFrom, dateTo, ItemCode, Group)
                           select new ReportSaleItemDTO()
                    {
                        //HeaderID = h.SaleHeaderID,
                        //CustomerName = h.CustomerName,
                        //ReceivedDate = h.ReceivedDate,
                        //SaleNumber = h.SaleNumber,
                        ItemCode = d.ItemCode,
                        ItemName = d.ItemName,
                        ItemPrice = d.ItemPrice.Value,
                        Amount = d.sumAmt.Value,
                    }).OrderBy(od => od.ItemCode).ToList();


                    //lst = (from h in cre.TransSaleHeaders
                    //       join d in cre.TransSaleDetails on h.SaleHeaderID equals d.SaleHeaderID
                    //       join i in cre.MasItems on d.ItemID equals i.ItemID
                    //       where i.ItemCode.Contains(ItemCode)
                    //       && h.ReceivedDate > dateFrom && h.ReceivedDate < dateTo
                    //       //&& dateFrom == DateTime.MinValue ? true : h.ReceivedDate.HasValue ? h.ReceivedDate.Value == date : true
                    //       select new ReportSaleItemDTO()
                    //       {
                    //           //HeaderID = h.SaleHeaderID,
                    //           //CustomerName = h.CustomerName,
                    //           //ReceivedDate = h.ReceivedDate,
                    //           //SaleNumber = h.SaleNumber,
                    //           ItemCode = i.ItemCode,
                    //           ItemName = i.ItemName,
                    //           ItemPrice = d.ItemPrice.Value,
                    //           Discount = d.Discount.Value,
                    //           Amount = d.Amount.Value,
                    //       }).OrderBy(od => od.ItemCode).ToList();
                };

                if (Group == "1")
                {
                    gv.Columns[3].Visible = true;
                    gv.Columns[4].Visible = true;
                }
                else
                {
                    gv.Columns[3].Visible = false;
                    gv.Columns[4].Visible = false;
                }

                if (lst != null && lst.Count > 0)
                {
                    //ModData(lst);
                    gv.DataSource             = lst;
                    Session["ReportSaleItem"] = lst;
                }
                else
                {
                    gv.DataSource = null;
                }

                gv.DataBind();
            }
            catch (Exception ex)
            {
                SendMailError(ex.Message, System.Reflection.MethodBase.GetCurrentMethod());
            }
        }
Beispiel #29
0
 public UserRoleRepository(BillingEntities context)
     : base(context)
 {
     AutoSave = true;
 }
Beispiel #30
0
 public LoginTrackingRepository(BillingEntities context)
     : base(context)
 {
     AutoSave = true;
     _context = context;
 }
Beispiel #31
0
 public DashboardBudgetRepository(BillingEntities context)
     : base(context)
 {
     AutoSave = true;
     _context = context;
 }
Beispiel #32
0
 public SystemConfigurationRepository(BillingEntities context)
     : base(context)
 {
     AutoSave = true;
 }
Beispiel #33
0
        protected void BindData()
        {
            try
            {
                List <ReportSummarySaleMonthDTO> lstResult = new List <ReportSummarySaleMonthDTO>();
                List <ReportSaleMonthDTO>        lst       = new List <ReportSaleMonthDTO>();
                List <MasValueList> lstVal = new List <MasValueList>();
                double   xx       = string.IsNullOrEmpty(txtXX.Text) ? 0 : Convert.ToDouble(txtXX.Text);
                double   MM200    = string.IsNullOrEmpty(txtMM200.Text) ? 0 : Convert.ToDouble(txtMM200.Text);
                double   MM225    = string.IsNullOrEmpty(txtMM225.Text) ? 0 : Convert.ToDouble(txtMM225.Text);
                string   Month    = ddlMonth.SelectedValue;
                string   Year     = ddlYear.SelectedValue;
                string   date     = "01/" + Month.PadLeft(2, '0') + "/" + Year;
                string   SaleName = ddlSaleName.SelectedItem.Text;
                DateTime dateFrom = DateTime.ParseExact(date, "dd/MM/yyyy", new System.Globalization.CultureInfo("en-US"));
                DateTime dateTo   = dateFrom.AddMonths(1).AddSeconds(-1);
                xx    = xx / 100;
                MM200 = MM200 / 100;
                MM225 = MM225 / 100;

                using (BillingEntities cre = new BillingEntities())
                {
                    lstVal = cre.MasValueLists.Where(w => w.FUNC.Equals("PAYMENT")).ToList();
                    lst    = (from h in cre.TransSaleHeaders
                              join d in cre.TransSaleDetails on h.SaleHeaderID equals d.SaleHeaderID
                              join i in cre.MasItems on d.ItemID equals i.ItemID
                              where h.ReceivedDate >= dateFrom && h.ReceivedDate < dateTo &&
                              (string.IsNullOrEmpty(SaleName) ? true : h.SaleName.Equals(SaleName))
                              //&& dateFrom == DateTime.MinValue ? true : h.ReceivedDate.HasValue ? h.ReceivedDate.Value == date : true
                              select new ReportSaleMonthDTO()
                    {
                        HeaderID = h.SaleHeaderID,
                        DetailID = d.SaleDetailID,
                        Remark = h.Remark,
                        CustomerName = h.CustomerName,
                        //CustomerAddress = h.CustomerAddress,
                        //CustomerDistrict = h.CustomerDistrict,
                        //CustomerCountry = h.CustomerCountry,
                        //CustomerProvince = h.CustomerProvince,
                        //CustomerPostalCode = h.CustomerPostalCode,
                        ReceivedDate = h.ReceivedDate,
                        //WarrantyDate = h.WarrantyDate,
                        SaleNumber = h.SaleNumber,
                        SaleName = h.SaleName,
                        ItemCode = i.ItemCode,
                        //ItemName = i.ItemName,
                        //SerialNumber = d.SerialNumber,
                        //ItemDescription = i.ItemDesc,
                        ItemPrice = d.ItemPrice.Value,
                        Discount = d.Discount.Value,
                        Amount = d.Amount.Value,
                        //Tel = h.Tel,
                        //Address = h.CustomerAddress,
                        //District = h.CustomerDistrict,
                        //Country = h.CustomerCountry,
                        //Province = h.CustomerProvince,
                        //PostalCode = h.CustomerPostalCode,
                        PayTypeID = h.PayType,
                        BillTypeID = h.BillType,
                        VAT = xx,
                        MAXMIG200 = MM200,
                        MAXMIG225 = MM225,
                        //VisImgBtn = "true",
                        ConsignmentNo = h.ConsignmentNo,
                        AccountTransfer = h.AccountTransfer,
                        Installment = h.Installment,
                    }).OrderBy(od => od.ReceivedDate).ThenBy(od => od.SaleNumber).ThenBy(od => od.DetailID).ToList();
                };

                if (lst != null && lst.Count > 0)
                {
                    lstResult     = ModData(lst, lstVal);
                    gv.DataSource = lstResult;
                    Session["ReportSummarySaleMonth"] = lstResult;
                }
                else
                {
                    gv.DataSource = null;
                }

                gv.DataBind();
            }
            catch (Exception ex)
            {
                SendMailError(ex.Message, System.Reflection.MethodBase.GetCurrentMethod());
            }
        }