Exemple #1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                // divAdd.Visible = ToolCode.Tool.GetUserMenuFunc("L0302", "Add");
                //divDelete.Visible = ToolCode.Tool.GetUserMenuFunc("L0302", "Delete");
                if (!ToolManager.CheckQueryString("Id"))
                {
                    Response.Write("请选择产成品、版本!");
                    Response.End();
                    return;
                }
                if (!ToolManager.CheckQueryString("Version"))
                {
                    Response.Write("请选择产成品、版本!");
                    Response.End();
                    return;
                }
                string    error = string.Empty;
                string    sql   = " select * from Product where ProductNumber='" + Server.UrlDecode(ToolManager.GetQueryString("Id")) + "' and Version='" + Server.UrlDecode(ToolManager.GetQueryString("Version")) + "'";
                DataTable dt    = DAL.SqlHelper.GetTable(sql, ref error);
                if (dt.Rows.Count <= 0)
                {
                    Response.Write("已删除该产成品编号、版本!请重新选择产成品、版本!");
                    Response.End();
                    return;
                }

                //删除
                if (ToolManager.CheckQueryString("ids"))
                {
                    string id      = ToolManager.GetQueryString("Id");
                    string temp    = ProductCustomerPropertyManager.DeleteData(ToolManager.GetQueryString("ids"));
                    bool   restult = temp == "1" ? true : false;
                    if (restult)
                    {
                        Tool.WriteLog(Tool.LogType.Operating, "删除产成品客户信息" + ToolManager.ReplaceSingleQuotesToBlank(id), "删除成功");
                        Response.Write(temp);
                        Response.End();
                        return;
                    }
                    else
                    {
                        Tool.WriteLog(Tool.LogType.Operating, "删除产成品客户信息" + ToolManager.ReplaceSingleQuotesToBlank(id), "删除失败!原因" + temp);
                        Response.Write(temp);
                        Response.End();
                        return;
                    }
                }
                //查询
                if (ToolManager.CheckQueryString("pageIndex"))
                {
                    GetPage("AddOrEditProductCustomerProperty.aspx", "btnSearch", "260", "600");
                }
            }
        }
Exemple #2
0
        private DataTable GetTable()
        {
            Dictionary <string, Dictionary <string, string> > productCustomerNames = ProductCustomerPropertyManager.GetProductCustomerNames();

            DataTable dtResult = SqlHelper.GetTable(GetSql());

            dtResult.Columns.Add("CustomerNames");
            foreach (DataRow dr in dtResult.Rows)
            {
                string key = dr["产成品编号"] + "|" + dr["版本"];
                if (productCustomerNames.ContainsKey(key))
                {
                    dr["CustomerNames"] = GetCustomerNames(productCustomerNames, key);;
                }
            }
            string customerName = txtCustomerName.Text.Trim();

            if (!string.IsNullOrEmpty(customerName))
            {
                DataRow[] tempRows = dtResult.Select("CustomerNames like '%" + customerName + "%'");

                if (tempRows != null && tempRows.Length > 0)
                {
                    dtResult = tempRows.CopyToDataTable <DataRow>();
                }
                else
                {
                    dtResult.Rows.Clear();
                }
            }
            if (dtResult != null && dtResult.Rows != null && dtResult.Rows.Count > 0)
            {
                double sumStockQty   = Convert.ToDouble(dtResult.Compute("sum(库存数量)", "true"));
                double sumStockPrice = Convert.ToDouble(dtResult.Compute("sum(库存金额)", "true"));

                DataRow sumRow = dtResult.NewRow();
                sumRow["库存数量"] = sumStockQty;
                sumRow["库存金额"] = sumStockPrice;
                dtResult.Rows.Add(sumRow);
            }
            return(dtResult);
        }
Exemple #3
0
        protected void btnUpload_Click(object sender, EventArgs e)
        {
            string  error = string.Empty;
            DataSet ds    = ToolManager.ImpExcel(this.FU_Excel, Server);

            if (ds == null)
            {
                lbMsg.Text = "选择的文件为空或不是标准的Excel文件!";
                return;
            }
            List <Product> products             = new List <Product>();
            List <ProductCustomerProperty> pcps = new List <ProductCustomerProperty>();

            foreach (DataRow dr in ds.Tables[0].Rows)
            {
                Product product = new Product();
                product.ProductNumber = dr["产成品编号"] == null ? "" : dr["产成品编号"].ToString();
                product.Version       = dr["版本"] == null ? "" : dr["版本"].ToString();;
                product.ProductName   = dr["名称"] == null ? "" : dr["名称"].ToString();
                product.Type          = dr["类别"] == null ? "" : dr["类别"].ToString();
                product.Description   = dr["描述"] == null ? "" : dr["描述"].ToString();
                if (dr["额定工时"] == null || dr["额定工时"].ToString() == "")
                {
                    product.RatedManhour = 0;
                }
                else
                {
                    product.RatedManhour = Convert.ToInt32(dr["额定工时"].ToString());
                }
                if (dr["报价工时"] == null || dr["报价工时"].ToString() == "")
                {
                    product.QuoteManhour = 0;
                }
                else
                {
                    product.QuoteManhour = Convert.ToInt32(dr["报价工时"].ToString());
                }
                if (dr["成本价"] == null || dr["成本价"].ToString() == "")
                {
                    product.CostPrice = Convert.ToDecimal(0.00);
                }
                else
                {
                    product.CostPrice = Convert.ToDecimal(dr["成本价"].ToString());
                }
                if (dr["销售报价"] == null || dr["销售报价"].ToString() == "")
                {
                    product.SalesQuotation = Convert.ToDecimal(0.00);
                }
                else
                {
                    product.SalesQuotation = Convert.ToDecimal(dr["销售报价"].ToString());
                }

                product.HalfProductPosition   = dr["半成品仓位"] == null ? "" : dr["半成品仓位"].ToString();
                product.FinishedGoodsPosition = dr["产成品仓位"] == null ? "" : dr["产成品仓位"].ToString();
                product.Remark = dr["备注"] == null ? "" : dr["备注"].ToString();
                products.Add(product);

                ProductCustomerProperty pcp = new ProductCustomerProperty();
                pcp.ProductNumber         = dr["产成品编号"] == null ? "" : dr["产成品编号"].ToString();
                pcp.Version               = dr["版本"] == null ? "" : dr["版本"].ToString();
                pcp.CustomerId            = dr["客户编号"] == null ? "" : dr["客户编号"].ToString();
                pcp.CustomerProductNumber = dr["客户产成品编号"] == null ? "" : dr["客户产成品编号"].ToString();
                pcps.Add(pcp);
            }
            bool result = ProductManager.BatchAddData(products, ref error);
            bool resultCustomerProduct = ProductCustomerPropertyManager.BatchAddData(pcps, ref error);

            if (result == true || resultCustomerProduct == true)
            {
                lbMsg.Text = "导入成功!";
            }
            else
            {
                lbMsg.Text = "导入失败!原因" + error;
            }
            if (result == true || resultCustomerProduct == true)
            {
                Tool.WriteLog(Tool.LogType.Operating, "导入产品信息", "导入成功!");
                return;
            }
            else
            {
                Tool.WriteLog(Tool.LogType.Operating, "导入产品信息", "导入失败!原因" + error);
                return;
            }
        }