protected void rptImportList_ItemCommand(object sender, RepeaterCommandEventArgs e)
        {
            switch (e.CommandName.ToLower())
            {
            case "delete":
                IvImport import = Module.GetById <IvImport>(Convert.ToInt32(e.CommandArgument));
                Module.Delete(import);
                BindrptImportList();
                break;

            default:
                break;
            }
        }
Ejemplo n.º 2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            Page.Title = @"Quản lý phiếu nhập";
            //rptProductList.RenderedItem =
            //    @"<tr class=""item"">                <td> <input type=""text"" placeholder=""Mã sản phẩm"" onfocus=""GetProduct(\'ajaxloader\',\'ctl00_ctl00_AdminContentMain_AdminContent_rptProductList_ctl█_txtCodeProduct\',\'ctl00_ctl00_AdminContentMain_AdminContent_rptProductList_ctl█_lblName,ajaxloader,ctl00_ctl00_AdminContentMain_AdminContent_rptProductList_ctl█_txtUnitPrice,ctl00_ctl00_AdminContentMain_AdminContent_rptProductList_ctl█_hddProductId\');"" onchange=""GetProduct(\'ajaxloader\',\'ctl00_ctl00_AdminContentMain_AdminContent_rptProductList_ctl█_txtCodeProduct\',\'ctl00_ctl00_AdminContentMain_AdminContent_rptProductList_ctl█_lblName,ajaxloader,ctl00_ctl00_AdminContentMain_AdminContent_rptProductList_ctl█_txtUnitPrice,ctl00_ctl00_AdminContentMain_AdminContent_rptProductList_ctl█_hddProductId\');"" id=""ctl00_ctl00_AdminContentMain_AdminContent_rptProductList_ctl█_txtCodeProduct"" value="""" name=""ct100$ctl00$AdminContentMain$AdminContent$rptProductList$ctl█$txtCodeProduct"">     <input type=""button"" class=""button"" value=""Chọn"" onclick=""buildUrl(\'ctl00_ctl00_AdminContentMain_AdminContent_rptProductList_ctl█_hddProductId\',\'ctl00_ctl00_AdminContentMain_AdminContent_rptProductList_ctl█_lblName\')"">                <input type=""hidden"" placeholder=""Tên sản phẩm"" value=""0"" id=""ctl00_ctl00_AdminContentMain_AdminContent_rptProductList_ctl█_hddProductImportId"" name=""ct100$ctl00$AdminContentMain$AdminContent$rptProductList$ctl█$hddProductImportId""> <input type=""hidden"" value=""0"" id=""ctl00_ctl00_AdminContentMain_AdminContent_rptProductList_ctl█_hddProductId"" name=""ct100$ctl00$AdminContentMain$AdminContent$rptProductList$ctl█$hddProductId""></td>            <td> <span id=""ctl00_ctl00_AdminContentMain_AdminContent_rptProductList_ctl█_lblName""></span> </td>            <td> <input type=""text"" placeholder=""Số luợng"" onchange=""Calculate(\'ctl00_ctl00_AdminContentMain_AdminContent_rptProductList_ctl█_txtUnitPrice\',\'ctl00_ctl00_AdminContentMain_AdminContent_rptProductList_ctl█_txtQuantity\',\'ctl00_ctl00_AdminContentMain_AdminContent_rptProductList_ctl█_txtTotal\');"" onkeyup=""Calculate(\'ctl00_ctl00_AdminContentMain_AdminContent_rptProductList_ctl█_txtUnitPrice\',\'ctl00_ctl00_AdminContentMain_AdminContent_rptProductList_ctl█_txtQuantity\',\'ctl00_ctl00_AdminContentMain_AdminContent_rptProductList_ctl█_txtTotal\');"" id=""ctl00_ctl00_AdminContentMain_AdminContent_rptProductList_ctl█_txtQuantity"" value=""0"" name=""ct100$ctl00$AdminContentMain$AdminContent$rptProductList$ctl█$txtQuantity""> </td>             <td> <input type=""text"" placeholder=""Đơn giá"" onchange=""Calculate(\'ctl00_ctl00_AdminContentMain_AdminContent_rptProductList_ctl█_txtUnitPrice\',\'ctl00_ctl00_AdminContentMain_AdminContent_rptProductList_ctl█_txtQuantity\',\'ctl00_ctl00_AdminContentMain_AdminContent_rptProductList_ctl█_txtTotal\');"" onkeyup=""Calculate(\'ctl00_ctl00_AdminContentMain_AdminContent_rptProductList_ctl█_txtUnitPrice\',\'ctl00_ctl00_AdminContentMain_AdminContent_rptProductList_ctl█_txtQuantity\',\'ctl00_ctl00_AdminContentMain_AdminContent_rptProductList_ctl█_txtTotal\');"" id=""ctl00_ctl00_AdminContentMain_AdminContent_rptProductList_ctl█_txtUnitPrice"" value=""0"" name=""ct100$ctl00$AdminContentMain$AdminContent$rptProductList$ctl█$txtUnitPrice""> </td>             <td> <input type=""text"" placeholder=""Thành tiền"" id=""ctl00_ctl00_AdminContentMain_AdminContent_rptProductList_ctl█_txtTotal"" value=""0"" name=""ct100$ctl00$AdminContentMain$AdminContent$rptProductList$ctl█$txtTotal""> </td>             <td> <input align=""absmiddle"" type=""image"" style=""border-width: 0px;"" onclick="""" alt=""Delete"" src=""/Images/delete_file.gif"" class=""image_button16"" title=""Delete"" id=""ctl00_ctl00_AdminContentMain_AdminContent_rptProductList_ctl█_btnDelete"" name=""ct100$ctl00$AdminContentMain$AdminContent$rptProductList$ctl█$btnDelete""> </td> </tr>";
            //rptProductList.HasHeader = true;
            //btnAddProductJava.Attributes.Add("onclick", rptProductList.AddItemScript);


            string argCode   = string.Format("document.getElementById({0}).value", "arg");
            string storageId = string.Format("document.getElementById('{0}').value", ddlStorage.ClientID);
            // Tạo đoạn code đăng ký phương thức callback, trong đó txtCode là tham số truyền vào call back, ValidateProductCode là phương thức xử lý dữ liệu callback
            string cbReference = Page.ClientScript.GetCallbackEventReference(this, argCode + "+" + "'|'" + "+" + storageId, "LoadProduct", "context",
                                                                             "LoadProduct", true);
            // Đăng ký phương thức vừa tạo
            string cbScript = "function UseCallback(arg,context)" + "{" + cbReference + ";" + "}";

            Page.ClientScript.RegisterClientScriptBlock(GetType(), "UseCallback", cbScript, true);

            if (!string.IsNullOrEmpty(Request.QueryString["ImportId"]))
            {
                _currentImport = Module.GetById <IvImport>(Convert.ToInt32(Request.QueryString["ImportId"]));
            }
            _ivUnits = Module.IvUnitGetAll(null);

            if (!IsPostBack)
            {
                LoadDataSelectList();
                int count = Module.CountImportByDateTime(Request.QueryString, UserIdentity, DateTime.Today) + 1;
                txtCode.Text = string.Format(@"PN{0}-{1}", DateTime.Today.ToString("ddMMyyyy"), count);
                txtName.Text = string.Format(@"Phiếu nhập ngày {0}-{1}", DateTime.Today.ToString("dd/MM/yyyy"), count);

                txtImportedDate.Text = DateTime.Today.ToString("dd/MM/yyyy");
                LoadInfoImport();
                if (CurrentImport.Id > 0)
                {
                    BindrptProductImportList();
                }
            }
        }
Ejemplo n.º 3
0
        public void PushImport(string imports)
        {
            InventoryServRes res = new InventoryServRes();

            res.BillFails        = new List <int>();
            res.ProductFails     = new List <int>();
            res.BillProductFails = new Dictionary <int, int>();
            try
            {
                if (!string.IsNullOrWhiteSpace(imports))
                {
                    var importDtos = JsonConvert.DeserializeObject <List <ImportDTO> >(imports);
                    if (importDtos.Count > 0)
                    {
                        foreach (var r in importDtos)
                        {
                            var count = Module.IvImportCheckByCode(r.Code);
                            if (count <= 0)
                            {
                                var import = new IvImport();

                                try
                                {
                                    if (r.ImportId > 0)
                                    {
                                        import = Module.GetById <IvImport>(r.ImportId);
                                    }
                                    import.ModifiedDate = r.ModifiedDate;
                                    import.Name         = r.Name;
                                    import.Code         = r.Code;
                                    import.CreatedDate  = r.CreatedDate;
                                    import.ImportedBy   = r.ImportedBy;
                                    import.Deleted      = r.Deleted;
                                    import.Detail       = r.Detail;
                                    if (r.StorageId > 0)
                                    {
                                        import.Storage = Module.IvStorageGetById(r.StorageId);
                                    }
                                    import.ImportDate = r.ImportDate;
                                    import.Total      = r.Total;
                                    if (r.AgencyId > 0)
                                    {
                                        import.Agency = Module.GetById <Agency>(r.AgencyId);
                                    }
                                    if (r.CruiseId > 0)
                                    {
                                        import.Cruise = Module.CruiseGetById(r.CruiseId);
                                    }
                                    Module.SaveOrUpdate(import);

                                    var isInsertProductSuccess = true;
                                    if (r.ImportProducts.Count > 0)
                                    {
                                        foreach (var p in r.ImportProducts)
                                        {
                                            try
                                            {
                                                var productImport = new IvProductImport();
                                                if (p.ImportProductId > 0)
                                                {
                                                    productImport = Module.GetById <IvProductImport>(p.ImportProductId);
                                                }

                                                productImport.Import = import;
                                                if (p.ProductId > 0)
                                                {
                                                    productImport.Product = Module.IvProductGetById(p.ProductId);
                                                }
                                                productImport.Quantity = p.Quantity;
                                                if (p.StorageId > 0)
                                                {
                                                    productImport.Storage = Module.IvStorageGetById(p.StorageId);
                                                }
                                                productImport.Total     = p.Total;
                                                productImport.UnitPrice = p.UnitPrice;
                                                if (p.UnitId > 0)
                                                {
                                                    productImport.Unit = Module.IvUnitGetById(p.UnitId);
                                                }
                                                Module.SaveOrUpdate(productImport);
                                            }
                                            catch (Exception e)
                                            {
                                                isInsertProductSuccess = false;
                                                res.ProductFails.Add(p.Id);
                                            }
                                        }
                                    }
                                    if (!isInsertProductSuccess)
                                    {
                                        res.BillProductFails.Add(r.Id, import.Id);
                                        res.BillFails.Add(r.Id);
                                    }
                                }
                                catch (Exception e)
                                {
                                    res.BillFails.Add(r.Id);
                                }
                            }
                        }
                    }
                }
                res.Status = "1";
                HttpContext.Current.Response.ContentType = "application/json";
                HttpContext.Current.Response.Charset     = "utf-8";
                HttpContext.Current.Response.Write(JsonConvert.SerializeObject(res));
            }
            catch (Exception e)
            {
                res.Status = "0";
                HttpContext.Current.Response.ContentType = "application/json";
                HttpContext.Current.Response.Charset     = "utf-8";
                HttpContext.Current.Response.Write(JsonConvert.SerializeObject(res));
            }
        }
        protected void rptImportList_ItemDataBound(object sender, RepeaterItemEventArgs e)
        {
            //if (e.Item.ItemType == ListItemType.Header)
            //{
            //    RepeaterOrder.FILE_NAME = "IvProductImportList.aspx";
            //    RepeaterOrder.SetOrderLink(e, "Name", Request.QueryString);
            //    RepeaterOrder.SetOrderLink(e, "Code", Request.QueryString);
            //    RepeaterOrder.SetOrderLink(e, "ImportDate", Request.QueryString);
            //    RepeaterOrder.SetOrderLink(e, "Total", Request.QueryString);
            //    RepeaterOrder.SetOrderLink(e, "ImportFrom", Request.QueryString);
            //    RepeaterOrder.SetOrderLink(e, "ImportedBy", Request.QueryString);

            //    return;
            //}
            if (e.Item.DataItem is IvImport)
            {
                IvImport import = (IvImport)e.Item.DataItem;

                HyperLink hplName = e.Item.FindControl("hplName") as HyperLink;
                if (hplName != null)
                {
                    hplName.Text        = import.Name;
                    hplName.NavigateUrl = string.Format("IvImportAdd.aspx?NodeId={0}&SectionID={1}&ImportId={2}", Node.Id, Section.Id, import.Id);
                }


                Label lblStorage = e.Item.FindControl("lblStorage") as Label;
                if (lblStorage != null)
                {
                    lblStorage.Text = import.Storage.Name;
                }
                Label lblCode = e.Item.FindControl("lblCode") as Label;
                if (lblCode != null)
                {
                    lblCode.Text = import.Code;
                }

                Label lblImportDate = e.Item.FindControl("lblImportDate") as Label;
                if (lblImportDate != null)
                {
                    lblImportDate.Text = import.ImportDate.ToString("dd/MM/yyyy");
                }

                Label lblImportedBy = e.Item.FindControl("lblImportedBy") as Label;
                if (lblImportedBy != null)
                {
                    lblImportedBy.Text = import.ImportedBy;
                }

                Label lblTotal = e.Item.FindControl("lblTotal") as Label;
                if (lblTotal != null)
                {
                    lblTotal.Text = import.Total.ToString("#,0.#");
                }

                Label lblSupp = e.Item.FindControl("lblSupp") as Label;
                if (lblSupp != null)
                {
                    if (import.Agency != null)
                    {
                        lblSupp.Text = import.Agency.Name;
                    }
                }

                HyperLink hplEdit = e.Item.FindControl("hplEdit") as HyperLink;
                if (hplEdit != null)
                {
                    hplEdit.NavigateUrl = string.Format("IvImportAdd.aspx?NodeId={0}&SectionId={1}&ImportId={2}", Node.Id,
                                                        Section.Id, import.Id);
                }
                var btnDelete = e.Item.FindControl("btnDelete") as ImageButton;
                if (btnDelete != null)
                {
                    if (!UserIdentity.HasPermission(AccessLevel.Administrator))
                    {
                        btnDelete.Visible = false;
                    }
                }
            }

            if (e.Item.ItemType == ListItemType.Footer)
            {
                Label lblTotalMonth = e.Item.FindControl("lblTotalMonth") as Label;
                if (lblTotalMonth != null)
                {
                    lblTotalMonth.Text = sumTotal.ToString("#,0.#");
                }
            }
        }