예제 #1
0
        protected void btnSend_Click(object sender, EventArgs e)
        {
            List <Dictionary <string, object> > newAddedList = Grid1.GetNewAddedList();

            if (newAddedList.Count == 0)
            {
                ShowNotify("没有要提交的数据");
                return;
            }


            String status = GetQueryValue("status");

            for (int i = 0; i < newAddedList.Count; i++)
            {
                string barcode = newAddedList[i]["barcode"].ToString();
                MYDB.purchaseorderDetail.Where(u => u.BarCode == barcode).Update(u => new PurchaseOrderDetail
                {
                    Status = int.Parse(status)
                });
            }


            MYDB.SaveChanges();

            ShowNotify("提交成功");

            //清除页面数据
            PageContext.RegisterStartupScript("clearLocalStorage()");
        }
예제 #2
0
        protected void btnNew_Click(object sender, EventArgs e)
        {
            try
            {
                string sortindex = "";
                if (Grid1.GetNewAddedList().Count != 0)
                {
                    List <Dictionary <string, object> > newAddedList = Grid1.GetNewAddedList();
                    sortindex = newAddedList[0]["SortIndex"].ToString();
                    sortindex = (int.Parse(sortindex) + 1).ToString();
                }
                else
                {
                    string sql = "select count(*)+1 from GoodsClass ";
                    SQLHelper.DbHelperSQL.SetConnectionString("");
                    sortindex = SQLHelper.DbHelperSQL.GetSingle(sql, 30);
                }
                // 新增数据初始值
                JObject defaultObj   = new JObject();
                string  deleteScript = GetDeleteScript();
                defaultObj.Add("ClassCode", "");
                defaultObj.Add("ClassName", "");
                defaultObj.Add("SortIndex", sortindex);

                defaultObj.Add("deleteField", String.Format("<a href=\"javascript:;\" onclick=\"{0}\"><img src=\"{1}\"/></a>", deleteScript, IconHelper.GetResolvedIconUrl(FineUIPro.Icon.Delete)));
                PageContext.RegisterStartupScript(Grid1.GetAddNewRecordReference(defaultObj, AppendToEnd));
            }
            catch (Exception ee)
            {
                Alert.Show(ee.ToString());
            }
        }
예제 #3
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            try
            {
                if (Grid1.GetModifiedData().Count == 0 && Grid1.GetNewAddedList().Count == 0)
                {
                    Alert.Show("表格数据没有变化!");
                    return;
                }
                ArrayList al = new ArrayList();
                string    sql = "", s = "";
                // 新增数据
                List <Dictionary <string, object> > newAddedList = Grid1.GetNewAddedList();
                for (int i = 0; i < newAddedList.Count; i++)
                {
                    sql = "insert into rlitems(itemno,itemname,Spec,Material,Price,SupplierId,UnitWeight,ProcessCost,ProcessCostType,SurfaceDeal,BaseNum,Sclass,WorkShop,MainFrom,StoreHouse,ProUsingQuantity,ZongCheng) values('" + newAddedList[i]["ItemNo"].ToString() + "','" + newAddedList[i]["ItemName"].ToString() + "','" + newAddedList[i]["Spec"].ToString() + "','" + newAddedList[i]["Material"].ToString() + "'," + newAddedList[i]["Price"].ToString() + "," + newAddedList[i]["SupplierId"].ToString() + "," + newAddedList[i]["UnitWeight"].ToString() + "," + newAddedList[i]["ProcessCost"].ToString() + ",'" + newAddedList[i]["ProcessCostType"].ToString() + "','" + newAddedList[i]["SurfaceDeal"].ToString() + "'," + newAddedList[i]["BaseNum"].ToString() + ",'" + newAddedList[i]["Sclass"].ToString() + "','" + newAddedList[i]["WorkShop"].ToString() + "','" + newAddedList[i]["MainFrom"].ToString() + "','" + newAddedList[i]["StoreHouse"].ToString() + "'," + newAddedList[i]["ProUsingQuantity"].ToString() + ",'" + newAddedList[i]["ZongCheng"].ToString() + "')";
                    log.Info("sql add item:" + sql);
                    al.Add(sql);
                }

                //Alert.Show(s);
                //return;
                //s = "";
                // 修改的现有数据
                Dictionary <int, Dictionary <string, object> > modifiedDict = Grid1.GetModifiedDict();
                SQLHelper.DbHelperSQL.SetConnectionString("");
                foreach (int rowIndex in modifiedDict.Keys)
                {
                    sql = "update rlitems set ";
                    for (int i = 0; i < Grid1.Columns.Count; i++)
                    {
                        if (modifiedDict[rowIndex].ContainsKey(Grid1.Columns[i].ColumnID))
                        {
                            sql += Grid1.Columns[i].ColumnID + "='" + modifiedDict[rowIndex][Grid1.Columns[i].ColumnID].ToString() + "',";
                        }
                    }
                    sql  = sql.TrimEnd(new char[] { ',' });
                    sql += " where sn=" + Grid1.DataKeys[rowIndex][0];
                    s   += sql + "------";
                    al.Add(sql);
                }


                SQLHelper.DbHelperSQL.SetConnectionString("");
                if (SQLHelper.DbHelperSQL.ExecuteSqlTran(al))
                {
                    Alert.Show("保存成功");
                    BindGrid();
                }
                else
                {
                    Alert.Show("保存失败");
                }
            }
            catch (Exception ee)
            {
                Alert.Show(ee.Message);
            }
        }
예제 #4
0
        /// <summary>
        ///     单元格编辑与修改
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void Grid1_AfterEdit(object sender, GridAfterEditEventArgs e)
        {
            Window1.Hidden = true;
            Window2.Hidden = true;
            Window3.Hidden = true;

            //新增行事件
            var addList = Grid1.GetNewAddedList();

            #region AddRow
            foreach (var add in addList)
            {
                var dictValues = add.Values;

                //商品代码
                var firstOrDefault = dictValues.First();

                if (firstOrDefault != null && !string.IsNullOrEmpty(firstOrDefault.ToString()))
                {
                    DataSet dataSet = GasHelper.GetSalesItem(firstOrDefault.ToString(), CurrentUser.AccountComId);

                    DataTable table = dataSet.Tables[0];

                    if (table != null && table.Rows.Count > 0)
                    {
                        //decimal price = GasHelper.GeCustomerPrice(txtFCode.Text.Trim(),//
                        //    table.Rows[0]["FItemCode"].ToString(), CurrentUser.AccountComId);

                        table.Rows[0]["FPrice"] = 0;

                        var details = new LHPassCardDetails
                        {
                            FItemCode     = table.Rows[0]["FItemCode"].ToString(),
                            FPrice        = 0,
                            FQty          = 1,
                            FAmount       = 0,
                            FBottleQty    = 0,
                            FBottleOweQty = 0,
                            FRecycleQty   = 0,
                            FCompanyId    = CurrentUser.AccountComId,
                            KeyId         = txtKeyId.Text.Trim(),
                            FBottle       = table.Rows[0]["FBottleCode"].ToString(),
                            FCateId       = Convert.ToInt32(table.Rows[0]["FId"].ToString())
                        };

                        StockOutDetailsService.Add(details);
                    }
                }
            }
            #endregion

            if (addList.Count > 0)
            {
                BindDataGrid();
            }
        }
예제 #5
0
        protected void Button2_Click(object sender, EventArgs e)
        {
            // 修改的现有数据
            Dictionary <int, Dictionary <string, object> > modifiedDict = Grid1.GetModifiedDict();

            foreach (int rowIndex in modifiedDict.Keys)
            {
                int     rowID = Convert.ToInt32(Grid1.DataKeys[rowIndex][0]);
                DataRow row   = FindRowByID(rowID);

                UpdateDataRow(modifiedDict[rowIndex], row);
            }


            // 删除现有数据
            List <int> deletedRows = Grid1.GetDeletedList();

            foreach (int rowIndex in deletedRows)
            {
                int rowID = Convert.ToInt32(Grid1.DataKeys[rowIndex][0]);
                DeleteRowByID(rowID);
            }


            // 新增数据
            List <Dictionary <string, object> > newAddedList = Grid1.GetNewAddedList();
            DataTable table = GetSourceData();

            if (AppendToEnd)
            {
                for (int i = 0; i < newAddedList.Count; i++)
                {
                    DataRow rowData = CreateNewData(table, newAddedList[i]);
                    table.Rows.Add(rowData);
                }
            }
            else
            {
                for (int i = newAddedList.Count - 1; i >= 0; i--)
                {
                    DataRow rowData = CreateNewData(table, newAddedList[i]);
                    table.Rows.InsertAt(rowData, 0);
                }
            }


            labResult.Text = String.Format("修改的数据:<pre>{0}</pre>", Grid1.GetModifiedData().ToString(Newtonsoft.Json.Formatting.Indented));


            BindGrid();

            ShowNotify("数据保存成功!(表格数据已重新绑定)");
        }
예제 #6
0
        protected void btn_save_Click(object sender, EventArgs e)
        {
            try
            {
                string curUser = GetUser();
                string sqlCmd  = "";
                // 修改的现有数据
                Dictionary <int, Dictionary <string, object> > modifiedDict = Grid1.GetModifiedDict();
                foreach (int rowIndex in modifiedDict.Keys)
                {
                    if (string.IsNullOrEmpty(Grid1.Rows[rowIndex].Values[0].ToString()))
                    {
                        Alert.ShowInTop("商品编码不可为空!");
                        return;
                    }
                    int rowID = Convert.ToInt32(Grid1.DataKeys[rowIndex][0]);
                    sqlCmd  = "update goodsList set goodsNo='" + Grid1.Rows[rowIndex].Values[0].ToString() + "',";
                    sqlCmd += "[goodsName]='" + Grid1.Rows[rowIndex].Values[1].ToString() + "',";
                    sqlCmd += "[specification]='" + Grid1.Rows[rowIndex].Values[2].ToString().Trim() + "',";
                    sqlCmd += "enabled='" + Convert.ToBoolean(Grid1.Rows[rowIndex].Values[3]) + "',";
                    sqlCmd += "[createDte]='" + DateTime.Now + "',[createUser]='" + curUser + "' ";
                    sqlCmd += "where id=" + rowID;
                    SqlSel_Pro.ExeSql(sqlCmd);
                }

                // 新增数据
                List <Dictionary <string, object> > newAddedList = Grid1.GetNewAddedList();
                for (int i = 0; i < newAddedList.Count; i++)
                {
                    //DataRow rowData = CreateNewData(table, newAddedList[i]);
                    //table.Rows.Add(rowData);
                    if (string.IsNullOrEmpty(newAddedList[i]["goodsNo"].ToString()))
                    {
                        Alert.ShowInTop("商品编码不可为空!");
                        return;
                    }
                    sqlCmd  = "insert into goodsList (goodsNo,goodsName,specification,enabled,createDte,createUser) values ";
                    sqlCmd += "('" + newAddedList[i]["goodsNo"].ToString().Trim() + "','" + newAddedList[i]["goodsName"].ToString() + "','" + newAddedList[i]["specification"].ToString().Trim() + "',";
                    sqlCmd += "'" + Convert.ToBoolean(newAddedList[i]["enabled"]) + "','" + DateTime.Now + "','" + curUser + "')";
                    SqlSel_Pro.ExeSql(sqlCmd);
                }
                //表格数据重新绑定
                bindGrid("ALL");

                Alert.Show("保存成功!");
            }
            catch (Exception ex)
            {
                Alert.ShowInTop(ex.Message);
                return;
            }
        }
예제 #7
0
        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            try
            {
                List <Dictionary <string, object> > newAddedList = Grid1.GetNewAddedList();
                if (newAddedList.Count > 0)
                {
                    string stepId = getStepId(ddl_flow.SelectedValue);

                    string sqlCmd = "insert into OA_OfficeSupply_Main (reqMan,reqDte,FlowId,CurrentStepID,others) values ('" + GetUser() + "','" + DateTime.Now + "',";
                    sqlCmd += "'" + ddl_flow.SelectedValue + "','" + stepId + "','" + txa_reason.Text + "')";
                    int exeCount = SqlSel.ExeSql(sqlCmd);
                    if (exeCount > 0)
                    {
                        //取当前单据id
                        sqlCmd = "select max(id) from OA_OfficeSupply_Main";
                        string formId = SqlSel.GetSqlScale(sqlCmd).ToString();
                        //插入申请明细
                        for (int i = 0; i < newAddedList.Count; i++)
                        {
                            string propertyName = newAddedList[i]["propertyName"].ToString();
                            string propertyNo   = propertyName.Substring(0, propertyName.IndexOf("-"));
                            sqlCmd  = "insert into OA_OfficeSupply_applyItem (officeSupplyId,propertyNo,applyCounts,applyUnit) values ('" + formId + "','" + propertyNo + "',";
                            sqlCmd += "'" + Convert.ToDecimal(newAddedList[i]["applyCounts"]) + "','" + newAddedList[i]["applyUnit"] + "')";
                            SqlSel.ExeSql(sqlCmd);
                        }

                        Alert.Show("提交成功!");
                        SimpleForm1.Reset();
                        Grid1.DataSource = null;
                        Grid1.DataBind();

                        pushMessage(stepId, "OA_OfficeSupply_Main", formId, "办公用品申请");
                    }
                    else
                    {
                        Alert.ShowInTop("提交失败!");
                        return;
                    }
                }
                else
                {
                    Alert.ShowInTop("尚未添加申领物品,不可提交!");
                    return;
                }
            }
            catch (Exception ex)
            {
                Alert.ShowInTop(ex.Message);
            }
        }
예제 #8
0
        protected void btn_save_Click(object sender, EventArgs e)
        {
            try
            {
                string sqlCmd = "";
                // 修改的现有数据
                Dictionary <int, Dictionary <string, object> > modifiedDict = Grid1.GetModifiedDict();
                foreach (int rowIndex in modifiedDict.Keys)
                {
                    if (string.IsNullOrEmpty(Grid1.Rows[rowIndex].Values[0].ToString()))
                    {
                        Alert.ShowInTop("资产名称不可为空!");
                        return;
                    }
                    int rowID = Convert.ToInt32(Grid1.DataKeys[rowIndex][0]);
                    sqlCmd  = "update OA_Property_Register set [propertyName]='" + Grid1.Rows[rowIndex].Values[0].ToString().Trim() + "',";
                    sqlCmd += "propertyNo='" + Grid1.Rows[rowIndex].Values[1].ToString().Trim() + "',";
                    sqlCmd += "BuyDate='" + Convert.ToDateTime(Grid1.Rows[rowIndex].Values[2]) + "',UseStatus='" + Convert.ToInt32(Grid1.Rows[rowIndex].Values[3]) + "',";
                    sqlCmd += "propertyType='" + Convert.ToInt32(Grid1.Rows[rowIndex].Values[4]) + "' ";
                    sqlCmd += "where id=" + rowID;
                    SqlSel.ExeSql(sqlCmd);
                }

                // 新增数据
                List <Dictionary <string, object> > newAddedList = Grid1.GetNewAddedList();
                for (int i = 0; i < newAddedList.Count; i++)
                {
                    //DataRow rowData = CreateNewData(table, newAddedList[i]);
                    //table.Rows.Add(rowData);
                    if (string.IsNullOrEmpty(newAddedList[i]["propertyName"].ToString()))
                    {
                        Alert.ShowInTop("资产名称不可为空!");
                        return;
                    }
                    sqlCmd  = "insert into OA_Property_Register (propertyName,propertyNo,BuyDate,UseStatus,propertyType) values ";
                    sqlCmd += "('" + newAddedList[i]["propertyName"].ToString().Trim() + "','" + newAddedList[i]["propertyNo"].ToString() + "','" + Convert.ToDateTime(newAddedList[i]["BuyDate"]) + "',";
                    sqlCmd += "'" + Convert.ToInt32(newAddedList[i]["UseStatus"]) + "','" + Convert.ToInt32(newAddedList[i]["propertyType"]) + "')";
                    Alert.Show(sqlCmd);
                    SqlSel.ExeSql(sqlCmd);
                }
                //表格数据重新绑定
                bindGrid();

                Alert.Show("保存成功!");
            }
            catch (Exception ex)
            {
                Alert.ShowInTop(ex.Message);
                return;
            }
        }
예제 #9
0
        protected void btnSend_Click(object sender, EventArgs e)
        {
            List <Dictionary <string, object> > newAddedList = Grid1.GetNewAddedList();

            if (newAddedList.Count == 0)
            {
                ShowNotify("没有要提交的数据");
                return;
            }


            String status = GetQueryValue("status");

            for (int i = 0; i < newAddedList.Count; i++)
            {
                result r   = result.合格;
                string res = newAddedList[i]["result"].ToString();
                switch (res)
                {
                case "合格":
                    r = result.合格;
                    break;

                case "不合格":
                    r = result.合格;
                    break;

                case "特采":
                    r = result.特采;
                    break;
                }

                decimal choujianqut = decimal.Parse(newAddedList[i]["choujianqut"].ToString());
                string  barcode     = newAddedList[i]["barcode"].ToString();
                MYDB.purchaseorderDetail.Where(u => u.BarCode == barcode).Update(u => new PurchaseOrderDetail
                {
                    Status      = int.Parse(status),
                    result      = r,
                    ChoujianQut = choujianqut,
                    CheckDate   = DateTime.Now
                });
            }

            MYDB.SaveChanges();

            ShowNotify("提交成功");

            //清除页面数据
            PageContext.RegisterStartupScript("clearLocalStorage()");
        }
예제 #10
0
        protected void btn_save_Click(object sender, EventArgs e)
        {
            try
            {
                string sqlCmd = "";
                // 修改的现有数据
                Dictionary <int, Dictionary <string, object> > modifiedDict = Grid1.GetModifiedDict();
                foreach (int rowIndex in modifiedDict.Keys)
                {
                    if (string.IsNullOrEmpty(Grid1.Rows[rowIndex].Values[0].ToString()))
                    {
                        Alert.ShowInTop("角色名不可为空!");
                        return;
                    }
                    int rowID = Convert.ToInt32(Grid1.DataKeys[rowIndex][0]);
                    sqlCmd  = "update OA_Sys_Role set roleName='" + Grid1.Rows[rowIndex].Values[0].ToString() + "',";
                    sqlCmd += "roleDesc='" + Grid1.Rows[rowIndex].Values[1].ToString() + "',";
                    sqlCmd += "UseStatus='" + Convert.ToBoolean(Grid1.Rows[rowIndex].Values[2]) + "',createDate='" + DateTime.Now + "' ";
                    sqlCmd += "where id=" + rowID;
                    SqlSel.ExeSql(sqlCmd);
                }

                // 新增数据
                List <Dictionary <string, object> > newAddedList = Grid1.GetNewAddedList();
                for (int i = 0; i < newAddedList.Count; i++)
                {
                    //DataRow rowData = CreateNewData(table, newAddedList[i]);
                    //table.Rows.Add(rowData);
                    if (string.IsNullOrEmpty(newAddedList[i]["roleName"].ToString()))
                    {
                        Alert.ShowInTop("角色名不可为空!");
                        return;
                    }
                    sqlCmd  = "insert into OA_Sys_Role (roleName,roleDesc,UseStatus,createDate) values ";
                    sqlCmd += "('" + newAddedList[i]["roleName"].ToString().Trim() + "','" + newAddedList[i]["roleDesc"].ToString() + "',";
                    sqlCmd += "'" + Convert.ToBoolean(newAddedList[i]["UseStatus"]) + "','" + DateTime.Now + "')";
                    SqlSel.ExeSql(sqlCmd);
                }
                //表格数据重新绑定
                bindGrid();

                Alert.Show("保存成功!");
            }
            catch (Exception ex)
            {
                Alert.ShowInTop(ex.Message);
                return;
            }
        }
예제 #11
0
        protected void btn_save_Click(object sender, EventArgs e)
        {
            try
            {
                string sqlCmd = "";
                // 修改的现有数据
                Dictionary <int, Dictionary <string, object> > modifiedDict = Grid1.GetModifiedDict();
                foreach (int rowIndex in modifiedDict.Keys)
                {
                    if (string.IsNullOrEmpty(Grid1.Rows[rowIndex].Values[0].ToString()))
                    {
                        Alert.ShowInTop("名称不可为空!");
                        return;
                    }
                    int rowID = Convert.ToInt32(Grid1.DataKeys[rowIndex][0]);
                    sqlCmd  = "update OA_DocMgmt_DocType set [type_name]='" + Grid1.Rows[rowIndex].Values[0].ToString() + "',";
                    sqlCmd += "[fl_desc]='" + Grid1.Rows[rowIndex].Values[1].ToString() + "' ";
                    sqlCmd += "where id=" + rowID;
                    SqlSel.ExeSql(sqlCmd);
                }

                // 新增数据
                List <Dictionary <string, object> > newAddedList = Grid1.GetNewAddedList();
                for (int i = 0; i < newAddedList.Count; i++)
                {
                    //DataRow rowData = CreateNewData(table, newAddedList[i]);
                    //table.Rows.Add(rowData);
                    if (string.IsNullOrEmpty(newAddedList[i]["type_name"].ToString()))
                    {
                        Alert.ShowInTop("名称不可为空!");
                        return;
                    }
                    sqlCmd  = "insert into OA_DocMgmt_DocType (type_name,pid,fl_desc,stat) values ";
                    sqlCmd += "('" + newAddedList[i]["type_name"].ToString().Trim() + "','0','" + newAddedList[i]["fl_desc"].ToString() + "','1')";
                    SqlSel.ExeSql(sqlCmd);
                }
                //表格数据重新绑定
                bindGrid();

                Alert.Show("保存成功!");
            }
            catch (Exception ex)
            {
                Alert.ShowInTop(ex.Message);
                return;
            }
        }
예제 #12
0
        protected void Grid1_AfterEdit(object sender, GridAfterEditEventArgs e)
        {
            try
            {
                string sortindex = "";
                if (Grid1.GetNewAddedList().Count != 0)
                {
                    List <Dictionary <string, object> > newAddedList = Grid1.GetNewAddedList();

                    string sql = "select count(*)+1 from BaseData where stype='" + newAddedList[newAddedList.Count - 1]["SType"].ToString() + "'";
                    SQLHelper.DbHelperSQL.SetConnectionString("");
                    sortindex = SQLHelper.DbHelperSQL.GetSingle(sql, 30);
                    Grid1.UpdateCellValue(e.RowIndex, e.ColumnID, sortindex);
                }
            }
            catch (Exception ee)
            {
                Alert.Show(ee.Message);
            }
        }
예제 #13
0
        protected void DeleteRowByID(int rowid)
        {
            List <Dictionary <string, object> > newAddedList = Grid1.GetNewAddedList();
            int find = -1;

            for (int i = 0; i < newAddedList.Count; i++)
            {
                if (rowid == Convert.ToInt32(newAddedList[i]["id"]))
                {
                    find = i;
                    GetDeleteScript();//前端数据直接脚本删除
                    break;
                }
            }

            if (find == -1)
            {
                deleteFromDb(rowid);
            }
        }
예제 #14
0
        protected void Grid1_PreDataBound(object sender, EventArgs e)
        {
            int             rowindex    = Convert.ToInt32(Grid1.DataKeys[Grid1.SelectedRowIndex][0]);
            LinkButtonField deleteField = Grid1.FindColumn("Delete") as LinkButtonField;

            List <Dictionary <string, object> > newAddedList = Grid1.GetNewAddedList();
            int find = -1;

            for (int i = 0; i < newAddedList.Count; i++)
            {
                if (rowindex == Convert.ToInt32(newAddedList[i]["id"]))
                {
                    find = i;
                    //GetDeleteScript();
                    deleteField.OnClientClick = GetDeleteScript();
                    break;
                }
            }

            if (find == -1)
            {
                deleteFromDb(rowindex);
            }
        }
예제 #15
0
        protected void btn_save_Click(object sender, EventArgs e)
        {
            try
            {
                string sqlCmd = "";
                // 修改的现有数据
                Dictionary <int, Dictionary <string, object> > modifiedDict = Grid1.GetModifiedDict();
                foreach (int rowIndex in modifiedDict.Keys)
                {
                    if (string.IsNullOrEmpty(Grid1.Rows[rowIndex].Values[0].ToString()) || string.IsNullOrEmpty(Grid1.Rows[rowIndex].Values[2].ToString()))
                    {
                        Alert.ShowInTop("商品编码或索菲亚编码不可为空!");
                        return;
                    }
                    if (Convert.ToBoolean(Grid1.Rows[rowIndex].Values[3]) == true & Convert.ToInt32(Grid1.Rows[rowIndex].Values[4]) == 0)
                    {
                        Alert.ShowInTop("不为最小单位的商品请添加计量数量!");
                        return;
                    }
                    int rowID = Convert.ToInt32(Grid1.DataKeys[rowIndex][0]);
                    sqlCmd  = "update t_MapGoodsList set goodsNo='" + Grid1.Rows[rowIndex].Values[0].ToString() + "',";
                    sqlCmd += "goodsSpec='" + Grid1.Rows[rowIndex].Values[1].ToString() + "',";
                    sqlCmd += "targetNo='" + Grid1.Rows[rowIndex].Values[2].ToString().Trim() + "',";
                    sqlCmd += "isMinUnitOrNo='" + Convert.ToBoolean(Grid1.Rows[rowIndex].Values[3]) + "',";
                    sqlCmd += "UnitTimes=" + Convert.ToInt32(Grid1.Rows[rowIndex].Values[4]) + ",isOrder='" + Convert.ToBoolean(Grid1.Rows[rowIndex].Values[5]) + "' ";
                    sqlCmd += "where id=" + rowID;
                    SqlSel_Pro.ExeSql(sqlCmd);
                }

                // 新增数据
                List <Dictionary <string, object> > newAddedList = Grid1.GetNewAddedList();
                DataTable table = createDataTable();
                for (int i = 0; i < newAddedList.Count; i++)
                {
                    //DataRow rowData = CreateNewData(table, newAddedList[i]);
                    //table.Rows.Add(rowData);
                    if (string.IsNullOrEmpty(newAddedList[i]["goodsNo"].ToString()) || string.IsNullOrEmpty(newAddedList[i]["targetNo"].ToString()))
                    {
                        Alert.ShowInTop("商品编码或索菲亚编码不可为空!");
                        return;
                    }
                    if (Convert.ToBoolean(newAddedList[i]["isMinUnitOrNo"]) == true & Convert.ToInt32(newAddedList[i]["UnitTimes"]) == 0)
                    {
                        Alert.ShowInTop("不为最小单位的商品请添加计量数量!");
                        return;
                    }
                    sqlCmd  = "insert into t_MapGoodsList (goodsNo,goodsSpec,targetNo,isMinUnitOrNo,UnitTimes,isOrder) values ";
                    sqlCmd += "('" + newAddedList[i]["goodsNo"].ToString().Trim() + "','" + newAddedList[i]["goodsSpec"].ToString() + "','" + newAddedList[i]["targetNo"].ToString().Trim() + "',";
                    sqlCmd += "'" + Convert.ToBoolean(newAddedList[i]["isMinUnitOrNo"]) + "'," + Convert.ToInt32(newAddedList[i]["UnitTimes"]) + ",'" + Convert.ToBoolean(newAddedList[i]["isOrder"]) + "')";
                    SqlSel_Pro.ExeSql(sqlCmd);
                }
                //表格数据重新绑定
                bindGrid("ALL");

                Alert.Show("保存成功!");
            }
            catch (Exception ex)
            {
                Alert.ShowInTop(ex.Message);
                return;
            }
        }
예제 #16
0
        protected void btn_save_Click(object sender, EventArgs e)
        {
            try
            {
                string sqlCmd = "";
                int    origGoodsId = 0, giftGoodsId = 0;
                // 修改的现有数据
                Dictionary <int, Dictionary <string, object> > modifiedDict = Grid1.GetModifiedDict();
                foreach (int rowIndex in modifiedDict.Keys)
                {
                    if (Convert.ToBoolean(Grid1.Rows[rowIndex].Values[2]) == true & (string.IsNullOrEmpty(Grid1.Rows[rowIndex].Values[0].ToString()) || string.IsNullOrEmpty(Grid1.Rows[rowIndex].Values[2].ToString())))
                    {
                        Alert.ShowInTop("商品编码或赠品编码不可为空!");
                        return;
                    }
                    int rowID = Convert.ToInt32(Grid1.DataKeys[rowIndex][0]);
                    origGoodsId = getGoodIdByNo(Grid1.Rows[rowIndex].Values[0].ToString().Trim());
                    giftGoodsId = getGoodIdByNo(Grid1.Rows[rowIndex].Values[1].ToString().Trim());
                    if (origGoodsId == 0 || giftGoodsId == 0)
                    {
                        Alert.ShowInTop("商品编码不存在,请校验!");
                        return;
                    }
                    sqlCmd  = "update SaleAct set origGoodsId=" + origGoodsId + ",";
                    sqlCmd += "giftGoodsId=" + giftGoodsId + ",";
                    sqlCmd += "enabled='" + Convert.ToBoolean(Grid1.Rows[rowIndex].Values[2]) + "',";
                    sqlCmd += "startDte='" + Convert.ToDateTime(Grid1.Rows[rowIndex].Values[3]) + "',";
                    sqlCmd += "endDte='" + Convert.ToDateTime(Grid1.Rows[rowIndex].Values[4]) + "' ";
                    sqlCmd += "where id=" + rowID;
                    SqlSel_Pro.ExeSql(sqlCmd);
                }

                // 新增数据
                List <Dictionary <string, object> > newAddedList = Grid1.GetNewAddedList();
                for (int i = 0; i < newAddedList.Count; i++)
                {
                    //DataRow rowData = CreateNewData(table, newAddedList[i]);
                    //table.Rows.Add(rowData);
                    if (Convert.ToBoolean(newAddedList[i]["enabled"]) == true & (string.IsNullOrEmpty(newAddedList[i]["goodsNo"].ToString()) || string.IsNullOrEmpty(newAddedList[i]["giftNo"].ToString())))
                    {
                        Alert.ShowInTop("商品编码或赠品编码不可为空!");
                        return;
                    }

                    origGoodsId = getGoodIdByNo(newAddedList[i]["goodsNo"].ToString().Trim());
                    giftGoodsId = getGoodIdByNo(newAddedList[i]["giftNo"].ToString().Trim());
                    if (origGoodsId == 0 || giftGoodsId == 0)
                    {
                        Alert.ShowInTop("商品编码不存在,请校验!");
                        return;
                    }

                    sqlCmd  = "insert into SaleAct (origGoodsId,giftGoodsId,enabled,startDte,endDte) values ";
                    sqlCmd += "(" + origGoodsId + "," + giftGoodsId + ",'" + Convert.ToBoolean(newAddedList[i]["enabled"]) + "',";
                    sqlCmd += "'" + Convert.ToDateTime(newAddedList[i]["startDte"]) + "','" + Convert.ToDateTime(newAddedList[i]["endDte"]) + "')";
                    SqlSel_Pro.ExeSql(sqlCmd);
                }
                //表格数据重新绑定
                bindGrid("ALL");

                Alert.Show("保存成功!");
            }
            catch (Exception ex)
            {
                Alert.ShowInTop(ex.Message);
                return;
            }
        }
예제 #17
0
        protected void btnSend_Click(object sender, EventArgs e)
        {
            List <Dictionary <string, object> > newAddedList = Grid1.GetNewAddedList();

            if (newAddedList.Count == 0)
            {
                ShowNotify("没有要提交的数据");
                return;
            }


            String status = GetQueryValue("status");

            for (int i = 0; i < newAddedList.Count; i++)
            {
                string barcode = newAddedList[i]["barcode"].ToString();
                MYDB.purchaseorderDetail.Where(u => u.BarCode == barcode).Update(u => new PurchaseOrderDetail
                {
                    Status = int.Parse(status)
                });
            }

            StockHeader stockHeader = new StockHeader();

            stockHeader.title   = "采购进货单";
            stockHeader.optdate = DateTime.Now;
            //执行存储过程获取流水号
            SQLHelper.DbHelperSQL.SetConnectionString("");
            object[]  obj              = new object[] { "JH" };
            DataTable dt               = SQLHelper.DbHelperSQL.ExecuteProc_ReturnDataTable("GetSeq", obj, 10);
            string    prosn            = dt.Rows[0][0].ToString();
            string    StockHeaderProsn = "JH" + prosn;

            ShowNotify(StockHeaderProsn);
            stockHeader.StockHeaderProsn = StockHeaderProsn;
            stockHeader.jingbanren       = GetChineseName();

            MYDB.StockHeaders.Add(stockHeader);

            for (int i = 0; i < newAddedList.Count; i++)
            {
                PurchaseStockList item = new PurchaseStockList();

                string barcode   = newAddedList[i]["barcode"].ToString();
                var    purdetail = MYDB.purchaseorderDetail.Where(u => u.BarCode == barcode).FirstOrDefault();

                item.Barcode = newAddedList[i]["barcode"].ToString();
                //订单号
                item.StockOrderNo = newAddedList[i]["saleno"].ToString();

                item.PurOrderNo = newAddedList[i]["orderno"].ToString();
                item.ItemNo     = newAddedList[i]["itemno"].ToString();
                item.ProNo      = newAddedList[i]["prono"].ToString();
                item.ItemName   = newAddedList[i]["itemname"].ToString();
                item.Spec       = newAddedList[i]["spec"].ToString();

                item.result      = purdetail.result;
                item.ChoujianQut = purdetail.ChoujianQut;
                item.checkDate   = purdetail.CheckDate;

                item.Quantity           = decimal.Parse(newAddedList[i]["qut"].ToString());
                item.Space              = newAddedList[i]["space"].ToString();
                item.Remark             = newAddedList[i]["remark"].ToString();
                item.PurchaseProperties = PurchaseProperties.采购入库;
                item.Mark             = "02";
                item.Unit             = newAddedList[i]["unit"].ToString();
                item.PDate            = DateTime.Now;
                item.StockHeaderProsn = StockHeaderProsn;

                MYDB.PurchaseStockLists.Add(item);
            }

            MYDB.SaveChanges();

            ShowNotify("提交成功");

            //清除页面数据
            PageContext.RegisterStartupScript("clearLocalStorage()");
        }
예제 #18
0
        protected void btn_save_Click(object sender, EventArgs e)
        {
            string msg = checkInput();

            if (msg != "")
            {
                Alert.Show(msg);
                return;
            }
            else
            {
                int iReturn = 0;
                try
                {
                    Entity.WasteToProduct entity = new Entity.WasteToProduct();
                    entity.CreateDate = DateTime.Now;
                    entity.UpdateDate = DateTime.Now;
                    entity.CreateUser = Request.Cookies["Cookies"].Values["UserName"].ToString();
                    entity.UpdateUser = Request.Cookies["Cookies"].Values["UserName"].ToString();
                    entity.DateTime   = FDate.SelectedDate;
                    entity.FromPondID = int.Parse(drop_Pond.SelectedValue);
                    entity.FromAmount = decimal.Parse(NB_Amount.Text);

                    entity.FromWasteCode = DAL.Pond.GetPond(int.Parse(drop_Pond.SelectedValue)).Stores;
                    entity.HanderManID   = int.Parse(hf_HandelManID.Text);
                    if (!string.IsNullOrEmpty(txt_Receiver.Text.Trim()))
                    {
                        entity.ReceiverID = int.Parse(hf_ReceiverID.Text);
                    }
                    else
                    {
                        entity.ReceiverID = 0;
                    }

                    entity.Status = 1;

                    if (string.IsNullOrEmpty(sGuid))
                    {
                        //Add
                        List <Dictionary <string, object> > newAddedList = Grid1.GetNewAddedList();
                        List <Entity.ProductDetail>         Adds         = new List <Entity.ProductDetail>();
                        for (int i = 0; i < newAddedList.Count; i++)
                        {
                            Entity.ProductDetail add = new Entity.ProductDetail();
                            add.Name     = newAddedList[i]["Name"].ToString();
                            add.PondID   = DAL.Pond.GetPondByName(add.Name).PondID;
                            add.Amount   = decimal.Parse(newAddedList[i]["Amount"].ToString());
                            add.ItemCode = DAL.Waste.GetWasteCodeByName(newAddedList[i]["WasteName"].ToString());
                            Adds.Add(add);
                        }

                        //List<Dictionary<string, object>> newAddedList2 = Grid2.GetNewAddedList();
                        //List<Entity.FinalWaste> Adds2 = new List<Entity.FinalWaste>();
                        //for (int i = 0; i < newAddedList2.Count; i++)
                        //{
                        //    Entity.FinalWaste add = new Entity.FinalWaste();
                        //    add.Result = decimal.Parse(newAddedList2[i]["Result2"].ToString());
                        //    add.ItemCode = DAL.Waste.GetWasteCodeByName(newAddedList2[i]["WasteName2"].ToString());
                        //    Adds2.Add(add);
                        //}

                        iReturn = DAL.WasteToProduct.AddWasteToProductEntity(entity, Adds);
                    }
                    else
                    {
                        //Update
                        entity.DealID = int.Parse(sGuid);
                        List <int> deletedRows = Grid1.GetDeletedList();
                        List <Entity.ProductDetail> Deletes = new List <Entity.ProductDetail>();
                        foreach (int rowIndex in deletedRows)
                        {
                            Entity.ProductDetail delete = new Entity.ProductDetail();
                            delete.DetailID = Convert.ToInt32(Grid1.DataKeys[rowIndex][1]);
                            Deletes.Add(delete);
                        }


                        Dictionary <int, Dictionary <string, object> > modifiedDict = Grid1.GetModifiedDict();
                        List <Entity.ProductDetail> Updates = new List <Entity.ProductDetail>();
                        foreach (int rowIndex in modifiedDict.Keys)
                        {
                            Entity.ProductDetail update = new Entity.ProductDetail();
                            update.DetailID = Convert.ToInt32(Grid1.DataKeys[rowIndex][1]);
                            update.ItemCode = DAL.Waste.GetWasteCodeByName(Grid1.DataKeys[rowIndex][2].ToString());
                            update.Amount   = decimal.Parse(Grid1.DataKeys[rowIndex][3].ToString());
                            update.PondID   = 1;
                            update.Status   = 1;
                            Updates.Add(update);
                        }

                        List <Dictionary <string, object> > newAddedList = Grid1.GetNewAddedList();
                        List <Entity.ProductDetail>         Adds         = new List <Entity.ProductDetail>();
                        for (int i = 0; i < newAddedList.Count; i++)
                        {
                            Entity.ProductDetail add = new Entity.ProductDetail();
                            add.Name     = newAddedList[i]["Name"].ToString();
                            add.PondID   = DAL.Pond.GetPondByName(add.Name).PondID;
                            add.Amount   = decimal.Parse(newAddedList[i]["Amount"].ToString());
                            add.ItemCode = DAL.Waste.GetWasteCodeByName(newAddedList[i]["WasteName"].ToString());
                            Adds.Add(add);
                        }


                        //List<int> deletedRows2 = Grid2.GetDeletedList();
                        //List<Entity.FinalWaste> Deletes2 = new List<Entity.FinalWaste>();
                        //foreach (int rowIndex in deletedRows2)
                        //{
                        //    Entity.FinalWaste delete = new Entity.FinalWaste();
                        //    delete.FWID = Convert.ToInt32(Grid2.DataKeys[rowIndex][1]);
                        //    Deletes2.Add(delete);
                        //}


                        //Dictionary<int, Dictionary<string, object>> modifiedDict2 = Grid2.GetModifiedDict();
                        //List<Entity.FinalWaste> Updates2 = new List<Entity.FinalWaste>();
                        //foreach (int rowIndex in modifiedDict2.Keys)
                        //{
                        //    Entity.FinalWaste update = new Entity.FinalWaste();
                        //    update.FWID = Convert.ToInt32(Grid2.DataKeys[rowIndex][1]);
                        //    update.ItemCode = DAL.Waste.GetWasteCodeByName(Grid2.DataKeys[rowIndex][2].ToString());
                        //    update.Result = decimal.Parse(Grid2.DataKeys[rowIndex][3].ToString());
                        //    update.Status = 1;
                        //    Updates2.Add(update);
                        //}

                        //List<Dictionary<string, object>> newAddedList2 = Grid2.GetNewAddedList();
                        //List<Entity.FinalWaste> Adds2 = new List<Entity.FinalWaste>();
                        //for (int i = 0; i < newAddedList2.Count; i++)
                        //{
                        //    Entity.FinalWaste add = new Entity.FinalWaste();
                        //    add.Result = decimal.Parse(newAddedList2[i]["Result2"].ToString());
                        //    add.ItemCode = DAL.Waste.GetWasteCodeByName(newAddedList2[i]["WasteName2"].ToString());
                        //    Adds2.Add(add);
                        //}
                        iReturn = DAL.WasteToProduct.UpdateWasteToProductEntity(entity, Adds, Updates, Deletes);
                    }
                }
                catch (Exception ex)
                {
                }
                finally
                {
                }
                if (iReturn == 1)
                {
                    Alert.ShowInTop(" 保存成功!", MessageBoxIcon.Information);
                    //            PageContext.RegisterStartupScript(ActiveWindow.GetHidePostBackReference());
                }
                else
                {
                    Alert.ShowInTop(" 保存失败!", MessageBoxIcon.Warning);
                }
            }
            #endregion
        }
예제 #19
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void Grid1_AfterEdit(object sender, GridAfterEditEventArgs e)
        {
            var addList = Grid1.GetNewAddedList();

            foreach (var add in addList)
            {
                var dictValues = add.Values;

                //商品代码
                var firstOrDefault = dictValues.First();

                if (firstOrDefault != null && !string.IsNullOrEmpty(firstOrDefault.ToString()))
                {
                    DataSet dataSet = GasHelper.GetPurchaseItem(firstOrDefault.ToString(), CurrentUser.AccountComId);

                    DataTable table = dataSet.Tables[0];

                    if (table != null && table.Rows.Count > 0)
                    {
                        decimal price = GasHelper.GeSupplierPrice(txtFCode.Text.Trim(),//
                                                                  table.Rows[0]["FItemCode"].ToString(), CurrentUser.AccountComId);

                        table.Rows[0]["FPrice"] = price;

                        var details = new LHStockInDetails
                        {
                            FItemCode     = table.Rows[0]["FItemCode"].ToString(),
                            FPrice        = price,
                            FQty          = 0,
                            FAmount       = price,
                            FBottleQty    = 0,
                            FReturnQty    = 0,
                            FBottleOweQty = 0,
                            FRecycleQty   = 0,
                            FCompanyId    = CurrentUser.AccountComId,
                            KeyId         = txtKeyId.Text.Trim(),
                            FBottle       = table.Rows[0]["FBottleCode"].ToString(),
                            FCateId       = Convert.ToInt32(table.Rows[0]["FId"].ToString())
                        };

                        switch (Actions)
                        {
                        case WebAction.Add:
                            break;

                        case WebAction.Edit:
                            //记录一下当前新增人操作内容
                            var detailslog = new LHStockInDetails_Log
                            {
                                FUpdateBy     = CurrentUser.AccountName,
                                FUpdateDate   = DateTime.Now,
                                FItemCode     = table.Rows[0]["FItemCode"].ToString(),
                                FPrice        = price,
                                FQty          = 1,
                                FAmount       = price,
                                FBottleQty    = 1,
                                FBottleOweQty = 0,
                                KeyId         = txtKeyId.Text.Trim(),
                                FBottle       = table.Rows[0]["FBottleCode"].ToString(),
                                FStatus       = "新增",
                                FCompanyId    = CurrentUser.AccountComId,
                                FMemo         = string.Format(@"时间:{0} 新增人:{1}", DateTime.Now, CurrentUser.AccountName)
                            };

                            StockInDetailsLogService.Add(detailslog);

                            break;
                        }


                        StockInDetailsService.Add(details);
                    }
                }
            }

            //var dictModified = Grid1.GetModifiedDict();

            //foreach (var index in dictModified.Keys)
            //{
            //    int datakey = Convert.ToInt32(Grid1.DataKeys[index][1].ToString());

            //    foreach (var dictValue in dictModified.Values)
            //    {
            //        foreach (KeyValuePair<string, object> keyValuePair in dictValue)
            //        {
            //            string key = keyValuePair.Key;
            //            string value = keyValuePair.Value.ToString();

            //            var details = StockInDetailsService.Where(p => p.FId == datakey&&p.FCompanyId==CurrentUser.AccountComId).FirstOrDefault();

            //            //写入原始,通过存储过程完成明细复制
            //            var parms = new Dictionary<string, object>();
            //            parms.Clear();

            //            parms.Add("@fid", datakey);
            //            parms.Add("@opr", CurrentUser.AccountName);
            //            parms.Add("@companyId", CurrentUser.AccountComId);
            //            SqlService.ExecuteProcedureCommand("proc_StockInDetails_Log", parms);

            //            if (details != null)
            //            {
            //                switch (key)
            //                {
            //                    case "FPrice":
            //                        details.FPrice = Convert.ToDecimal(value);
            //                        details.FAmount = details.FPrice * details.FQty;
            //                        break;

            //                    case "FQty":
            //                        details.FQty = Convert.ToDecimal(value);
            //                        details.FAmount = details.FPrice * details.FQty;
            //                        break;

            //                    case "FBottle":
            //                        details.FBottle = value;
            //                        break;

            //                    case "FBottleName":
            //                        details.FBottle = value;
            //                        break;

            //                    case "FBottleQty":
            //                        details.FBottleQty = Convert.ToInt32(value);
            //                        break;

            //                    case "FMemo":
            //                        details.FMemo = value;
            //                        break;
            //                }

            //                var detailslog = new LHStockInDetails_Log
            //                {
            //                    FUpdateBy = CurrentUser.AccountName,
            //                    FUpdateDate = DateTime.Now,
            //                    FItemCode = details.FItemCode,
            //                    FPrice = details.FPrice,
            //                    FQty = details.FQty,
            //                    FAmount = details.FAmount,
            //                    FBottleQty = details.FBottleQty,
            //                    FBottleOweQty = details.FBottleOweQty,
            //                    KeyId = details.KeyId,
            //                    FBottle = details.FBottle,
            //                    FStatus = "变更",
            //                    FCompanyId = CurrentUser.AccountComId,
            //                    FMemo = string.Format(@"时间:{0} 变更人:{1}", DateTime.Now, CurrentUser.AccountName)
            //                };
            //                StockInDetailsLogService.Add(detailslog);

            //            }

            //            StockInDetailsService.SaveChanges();
            //        }
            //    }
            //}

            if (addList.Count > 0)
            {
                BindDataGrid();
            }
        }
예제 #20
0
        /// <summary>
        ///     AddListGrid
        /// </summary>
        private void AddListGrid()
        {
            //新增行事件
            var dictList = Grid1.GetNewAddedList();

            foreach (var rowKey in dictList)
            {
                var sKeys   = new StringBuilder();
                var sValues = new StringBuilder();
                foreach (var key in rowKey.Keys)
                {
                    sKeys.AppendFormat("{0},", key);
                }

                foreach (var dictValue in rowKey.Values)
                {
                    sValues.AppendFormat("{0},", dictValue);
                }

                var keys   = sKeys.ToString().Split(',');
                var values = sValues.ToString().Split(',');

                var details = new LHLiquidPlan();

                for (int i = 0; i < keys.Count(); i++)
                {
                    #region 修改内容

                    var key   = keys[i];
                    var value = values[i];

                    if (!string.IsNullOrEmpty(key) && key.Length > 0)
                    {
                        if (details != null)
                        {
                            #region Add

                            if (key.Equals("KeyId"))
                            {
                                details.KeyId = value;
                            }

                            if (key.Equals("FDate"))
                            {
                                details.FDate = Convert.ToDateTime(value);
                            }

                            if (key.Equals("FItemName"))//产品
                            {
                                details.FItemCode = value;

                                if (!string.IsNullOrEmpty(value))
                                {
                                    details.FItemName =
                                        ItemsService.FirstOrDefault(
                                            p => p.FCode == value && p.FCompanyId == CurrentUser.AccountComId).FName;
                                }
                            }

                            if (key.Equals("FBill"))
                            {
                                details.FBill = value;
                            }

                            //if (key.Equals("FDriver"))
                            //{
                            //    details.FDriver = value;
                            //}

                            if (key.Equals("FSupercargo"))
                            {
                                details.FSupercargo = value;
                            }

                            if (key.Equals("FVehicleNum"))
                            {
                                details.FVehicleNum = value;

                                if (value != null && !string.IsNullOrEmpty(value))
                                {
                                    var vehicle = new VehicleService().FirstOrDefault(p => p.FNum == value);

                                    details.FMargin = Convert.ToDecimal(vehicle.FMargin);
                                }
                            }

                            //if (key.Equals("FMargin"))
                            //{
                            //    details.FMargin = Convert.ToDecimal(value);
                            //}

                            if (key.Equals("FPurchasedDate"))
                            {
                                details.FPurchasedDate = value;
                            }

                            if (key.Equals("FSupplierName"))
                            {
                                details.FSupplierCode = value;
                                if (!string.IsNullOrEmpty(value))
                                {
                                    details.FSupplierName =
                                        SupplierService.FirstOrDefault(
                                            p => p.FCode == value && p.FCompanyId == CurrentUser.AccountComId).FName;
                                }
                            }

                            if (key.Equals("FPurchasedPrice"))
                            {
                                details.FPurchasedPrice = Convert.ToDecimal(value);
                                details.FAmt            = details.FPurchasedPrice * details.FPurchasedQty;
                            }

                            if (key.Equals("FPurchasedQty"))
                            {
                                details.FPurchasedQty = Convert.ToDecimal(value);
                                details.FAmt          = details.FPurchasedPrice * details.FPurchasedQty;
                            }

                            //--------------------------------------

                            if (key.Equals("FDate1"))
                            {
                                details.FDate1 = Convert.ToDateTime(value);
                            }

                            if (key.Equals("FName1"))
                            {
                                details.FCode1 = value;
                                if (!string.IsNullOrEmpty(value))
                                {
                                    details.FName1 =
                                        CustomerService.FirstOrDefault(
                                            p => p.FCode == value && p.FCompanyId == CurrentUser.AccountComId).FName;
                                }
                            }

                            if (key.Equals("FPrice1"))
                            {
                                details.FPrice1 = Convert.ToDecimal(value);
                                details.FAmt1   = details.FPrice1 * details.FQty1;
                            }

                            if (key.Equals("FQty1"))
                            {
                                details.FQty1 = Convert.ToDecimal(value);
                                details.FAmt1 = details.FPrice1 * details.FQty1;
                            }

                            //--------------------

                            if (key.Equals("FDate2"))
                            {
                                details.FDate2 = Convert.ToDateTime(value);
                            }

                            if (key.Equals("FName2"))
                            {
                                details.FCode2 = value;
                                if (!string.IsNullOrEmpty(value))
                                {
                                    details.FName2 =
                                        CustomerService.FirstOrDefault(
                                            p => p.FCode == value && p.FCompanyId == CurrentUser.AccountComId).FName;
                                }
                            }

                            if (key.Equals("FPrice2"))
                            {
                                details.FPrice2 = Convert.ToDecimal(value);
                                details.FAmt2   = details.FPrice2 * details.FQty2;
                            }

                            if (key.Equals("FQty2"))
                            {
                                details.FQty2 = Convert.ToDecimal(value);
                                details.FAmt2 = details.FPrice2 * details.FQty2;
                            }

                            //--------------------

                            if (key.Equals("FDat3"))
                            {
                                details.FDate3 = Convert.ToDateTime(value);
                            }

                            if (key.Equals("FName3"))
                            {
                                details.FCode3 = value;
                                if (!string.IsNullOrEmpty(value))
                                {
                                    details.FName3 =
                                        CustomerService.FirstOrDefault(
                                            p => p.FCode == value && p.FCompanyId == CurrentUser.AccountComId).FName;
                                }
                            }

                            if (key.Equals("FPrice3"))
                            {
                                details.FPrice3 = Convert.ToDecimal(value);
                                details.FAmt3   = details.FPrice3 * details.FQty3;
                            }

                            if (key.Equals("FQty3"))
                            {
                                details.FQty3 = Convert.ToDecimal(value);
                                details.FAmt3 = details.FPrice3 * details.FQty3;
                            }
                            //--------------------

                            if (key.Equals("FMarginEnd"))
                            {
                                details.FMarginEnd = Convert.ToDecimal(value);
                            }

                            if (key.Equals("FMemo"))
                            {
                                details.FMemo = value;
                            }


                            #endregion
                        }
                    }

                    #endregion
                }

                string keyId = SequenceService.CreateSequence(Convert.ToDateTime(details.FDate), "LP", CurrentUser.AccountComId);
                details.KeyId       = keyId;
                details.FDeleteFlag = 0;
                details.FType       = 26;
                details.FFlag       = 1;
                details.CreateBy    = CurrentUser.AccountName;
                details.FStatus     = 10;

                details.FCompanyId = CurrentUser.AccountComId;
                LiquidPlanService.Add(details);

                var refuel = new LHLiquidRefuel
                {
                    FFlag      = 1,
                    CreateBy   = CurrentUser.AccountName,
                    FDate      = details.FDate,
                    KeyId      = details.KeyId,
                    FCompanyId = CurrentUser.AccountComId
                };
                LiquidRefuelService.Add(refuel);
            }

            Grid1.CommitChanges();
        }
예제 #21
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            try
            {
                if (Grid1.GetModifiedData().Count == 0 && Grid1.GetNewAddedList().Count == 0)
                {
                    Alert.Show("表格数据没有变化!");
                    return;
                }
                ArrayList al = new ArrayList();
                string    sql = "", s = "";
                // 新增数据
                List <Dictionary <string, object> > newAddedList = Grid1.GetNewAddedList();
                for (int i = 0; i < newAddedList.Count; i++)
                {
                    //s += newAddedList[i]["ItemNo"].ToString() + "----" + newAddedList[i]["Name"].ToString() + "----" + newAddedList[i]["Spec"].ToString() + "----" + newAddedList[i]["MaterialNo"].ToString() + "----" + newAddedList[i]["ItemColor"].ToString();
                    sql = "insert into OrderHeader(OrderNo,ClientOrderNo,LotNo,ClientCode,RecOrderPerson,RecOrderDate,SendOrderDate,OutGoodsDate,Inputer,InputerDate) values('" + newAddedList[i]["OrderNo"].ToString() + "','" + newAddedList[i]["ClientOrderNo"].ToString() + "','" + newAddedList[i]["LotNo"].ToString() + "','" + newAddedList[i]["ClientCode"].ToString() + "','" + newAddedList[i]["RecOrderPerson"].ToString() + "','" + newAddedList[i]["RecOrderDate"].ToString() + "','" + newAddedList[i]["SendOrderDate"].ToString() + "','" + newAddedList[i]["OutGoodsDate"].ToString() + "','" + newAddedList[i]["Inputer"].ToString() + "','" + newAddedList[i]["InputerDate"].ToString() + "')";
                    s  += sql + "---";
                    al.Add(sql);
                }

                //Alert.Show(s);
                //return;
                //s = "";
                // 修改的现有数据
                Dictionary <int, Dictionary <string, object> > modifiedDict = Grid1.GetModifiedDict();
                SQLHelper.DbHelperSQL.SetConnectionString("");
                foreach (int rowIndex in modifiedDict.Keys)
                {
                    sql = "update OrderHeader set ";
                    for (int i = 0; i < Grid1.Columns.Count; i++)
                    {
                        if (modifiedDict[rowIndex].ContainsKey(Grid1.Columns[i].ColumnID))
                        {
                            sql += Grid1.Columns[i].ColumnID + "='" + modifiedDict[rowIndex][Grid1.Columns[i].ColumnID].ToString() + "',";
                        }
                    }
                    sql  = sql.TrimEnd(new char[] { ',' });
                    sql += " where sn=" + Grid1.DataKeys[rowIndex][0];
                    s   += sql + "------";
                    al.Add(sql);
                }
                //al.Add(sql);


                SQLHelper.DbHelperSQL.SetConnectionString("");
                if (SQLHelper.DbHelperSQL.ExecuteSqlTran(al))
                {
                    Alert.Show("保存成功");
                    BindGrid();
                }
                else
                {
                    Alert.Show("保存失败");
                }
            }
            catch (Exception ee)
            {
                Alert.Show(ee.Message);
            }
        }
예제 #22
0
        private void GridEdit()
        {
            #region update
            var dictModified = Grid1.GetModifiedDict();
            foreach (var rowKey in dictModified.Keys)
            {
                int datakey = Convert.ToInt32(Grid1.DataKeys[rowKey][1].ToString());

                var sKeys   = new StringBuilder();
                var sValues = new StringBuilder();
                foreach (var key in dictModified[rowKey].Keys)
                {
                    sKeys.AppendFormat("{0},", key);
                }

                foreach (var dictValue in dictModified[rowKey].Values)
                {
                    sValues.AppendFormat("{0},", dictValue);
                }

                var details = CustomerLinkService.Where(p => p.FId == datakey && p.FCompanyId == CurrentUser.AccountComId).FirstOrDefault();
                var keys    = sKeys.ToString().Split(',');
                var values  = sValues.ToString().Split(',');
                for (int i = 0; i < keys.Count(); i++)
                {
                    #region 修改内容

                    var key   = keys[i];
                    var value = values[i];

                    if (!string.IsNullOrEmpty(key))
                    {
                        if (details != null)
                        {
                            if (key.Equals("FLinkman"))
                            {
                                details.FLinkman = value;
                            }

                            if (key.Equals("FAddress"))
                            {
                                details.FAddress = value;
                            }

                            if (key.Equals("FPhome"))
                            {
                                details.FPhome = value;
                            }

                            if (key.Equals("FMoile"))
                            {
                                details.FMoile = value;
                            }

                            if (key.Equals("FMemo"))
                            {
                                details.FMemo = value;
                            }

                            if (key.Equals("FType"))
                            {
                                details.FType = value;
                            }
                        }
                    }

                    #endregion
                }


                CustomerLinkService.SaveChanges();
            }
            #endregion


            var addList = Grid1.GetNewAddedList();

            #region AddRow
            foreach (var add in addList)
            {
                var sKeys   = new StringBuilder();
                var sValues = new StringBuilder();
                foreach (var key in add.Keys)
                {
                    sKeys.AppendFormat("{0},", key);
                }

                foreach (var dictValue in add.Values)
                {
                    sValues.AppendFormat("{0},", dictValue);
                }

                var keys    = sKeys.ToString().Split(',');
                var values  = sValues.ToString().Split(',');
                var details = new LHCustomerLink();
                for (int i = 0; i < keys.Count(); i++)
                {
                    #region 修改内容


                    details.FCompanyId = CurrentUser.AccountComId;
                    details.FCode      = FCode;

                    var key   = keys[i];
                    var value = values[i];

                    if (!string.IsNullOrEmpty(key))
                    {
                        if (key.Equals("FLinkman"))
                        {
                            details.FLinkman = value;
                        }

                        if (key.Equals("FAddress"))
                        {
                            details.FAddress = value;
                        }

                        if (key.Equals("FPhome"))
                        {
                            details.FPhome = value;
                        }

                        if (key.Equals("FMoile"))
                        {
                            details.FMoile = value;
                        }

                        if (key.Equals("FMemo"))
                        {
                            details.FMemo = value;
                        }

                        if (key.Equals("FType"))
                        {
                            details.FType = value;
                        }
                    }

                    #endregion
                }
                CustomerLinkService.Add(details);
            }
            #endregion
        }
예제 #23
0
        /// <summary>
        ///     单元格编辑与修改
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void Grid1_AfterEdit(object sender, GridAfterEditEventArgs e)
        {
            Window1.Hidden = true;
            Window2.Hidden = true;
            Window3.Hidden = true;

            //新增行事件
            var addList = Grid1.GetNewAddedList();

            #region AddRow
            foreach (var add in addList)
            {
                var dictValues = add.Values;

                //商品代码
                var firstOrDefault = dictValues.First();

                if (firstOrDefault != null && !string.IsNullOrEmpty(firstOrDefault.ToString()))
                {
                    DataSet dataSet = GasHelper.GetSalesItem(firstOrDefault.ToString(), CurrentUser.AccountComId);

                    DataTable table = dataSet.Tables[0];

                    if (table != null && table.Rows.Count > 0)
                    {
                        decimal price = GasHelper.GeCustomerPrice(txtFCode.Text.Trim(),//
                                                                  table.Rows[0]["FItemCode"].ToString(), CurrentUser.AccountComId);

                        table.Rows[0]["FPrice"] = price;

                        var details = new LHBottleDetectionDetails
                        {
                            FItemCode     = table.Rows[0]["FItemCode"].ToString(),
                            FPrice        = price,
                            FQty          = 1,
                            FAmount       = price,
                            FBottleQty    = 0,
                            FBottleOweQty = 0,
                            FRecycleQty   = 0,
                            FCompanyId    = CurrentUser.AccountComId,
                            KeyId         = txtKeyId.Text.Trim(),
                            FBottle       = table.Rows[0]["FBottleCode"].ToString(),
                            FCateId       = Convert.ToInt32(table.Rows[0]["FId"].ToString())
                        };

                        switch (Actions)
                        {
                        case WebAction.Add:
                            break;

                        case WebAction.Edit:
                            //记录一下当前新增人操作内容
                            //var detailslog = new LHStockOutDetails_Log
                            //{
                            //    FUpdateBy = CurrentUser.AccountName,
                            //    FUpdateDate = DateTime.Now,
                            //    FItemCode = table.Rows[0]["FItemCode"].ToString(),
                            //    FPrice = price,
                            //    FQty = 1,
                            //    FAmount = price,
                            //    FBottleQty = 0,
                            //    FCompanyId = CurrentUser.AccountComId,
                            //    FBottleOweQty = 0,
                            //    KeyId = txtKeyId.Text.Trim(),
                            //    FBottle = table.Rows[0]["FBottleCode"].ToString(),
                            //    FStatus = "新增",
                            //    FMemo = string.Format(@"时间:{0} 新增人:{1}", DateTime.Now, CurrentUser.AccountName)
                            //};

                            //StockOutDetailsLogService.Add(detailslog);

                            break;
                        }

                        BottleDetectionDetailsService.Add(details);
                    }
                }
            }
            #endregion

            if (addList.Count > 0)
            {
                BindDataGrid();
            }
        }
예제 #24
0
        protected void btnSave2_Click(object sender, EventArgs e)
        {
            try
            {
                if (Grid1.GetModifiedData().Count == 0 && Grid1.GetNewAddedList().Count == 0)
                {
                    Alert.Show("表格数据没有变化!");
                    return;
                }
                ArrayList al = new ArrayList();
                string    sql = "", s = "";
                if (Grid1.GetNewAddedList().Count != 0)
                {
                    // 新增数据
                    List <Dictionary <string, object> > newAddedList = Grid1.GetNewAddedList();
                    for (int i = 0; i < newAddedList.Count; i++)
                    {
                        //s += newAddedList[i]["ItemNo"].ToString() + "----" + newAddedList[i]["Name"].ToString() + "----" + newAddedList[i]["Spec"].ToString() + "----" + newAddedList[i]["MaterialNo"].ToString() + "----" + newAddedList[i]["ItemColor"].ToString();
                        sql = "insert into AllItem(ItemNo,Name,Spec,MaterialNo,ItemColor,AddReserve1,ClassName) values('" + newAddedList[i]["ItemNo"].ToString() + "','" + newAddedList[i]["Name"].ToString() + "','" + newAddedList[i]["Spec"].ToString() + "','" + newAddedList[i]["MaterialNo"].ToString() + "','" + newAddedList[i]["ItemColor"].ToString() + "','" + newAddedList[i]["AddReserve1"].ToString() + "','" + newAddedList[i]["ClassName"].ToString() + "')";
                        s  += sql + "---";
                        al.Add(sql);
                    }
                }
                //Alert.Show(s);
                //return;
                //s = "";
                if (Grid1.GetModifiedData().Count != 0)
                {
                    // 修改的现有数据
                    Dictionary <int, Dictionary <string, object> > modifiedDict = Grid1.GetModifiedDict();
                    SQLHelper.DbHelperSQL.SetConnectionString("");
                    foreach (int rowIndex in modifiedDict.Keys)
                    {
                        sql = "update AllItem set ";
                        for (int i = 0; i < Grid1.Columns.Count; i++)
                        {
                            if (modifiedDict[rowIndex].ContainsKey(Grid1.Columns[i].ColumnID))
                            {
                                sql += Grid1.Columns[i].ColumnID + "='" + modifiedDict[rowIndex][Grid1.Columns[i].ColumnID].ToString() + "',";
                            }
                        }
                        sql  = sql.TrimEnd(new char[] { ',' });
                        sql += " where sn=" + Grid1.DataKeys[rowIndex][0];
                        //s += sql + "------";
                        al.Add(sql);
                    }
                }
                //al.Add(sql);
                //sql = "update AllItem set ItemNo='" + modifiedDict[rowIndex]["ItemNo"].ToString() + "',Name='" + modifiedDict[rowIndex]["Name"].ToString() + "',Spec='" + modifiedDict[rowIndex]["Spec"].ToString() + "',MaterialNo='" + modifiedDict[rowIndex]["MaterialNo"].ToString() + "',ItemColor='" + modifiedDict[rowIndex]["ItemColor"].ToString() + "',AddReserve1='" + modifiedDict[rowIndex]["AddReserve1"].ToString() + "',ClassName='" + modifiedDict[rowIndex]["ClassName"].ToString() + "' where sn=" + GetSelectedDataKeyID(Grid1);
                //Alert.Show(s);

                SQLHelper.DbHelperSQL.SetConnectionString("");
                if (SQLHelper.DbHelperSQL.ExecuteSqlTran(al))
                {
                    Alert.Show("保存成功");
                    BindGrid();
                }
                else
                {
                    Alert.Show("保存失败");
                }
            }
            catch (Exception ee)
            {
                Alert.Show(ee.Message);
            }
        }
예제 #25
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            try
            {
                if (Grid1.GetModifiedData().Count == 0 && Grid1.GetNewAddedList().Count == 0)
                {
                    Alert.Show("表格数据没有变化!");
                    return;
                }
                ArrayList al = new ArrayList();
                string    sql = "", s = "";
                // 新增数据
                SQLHelper.DbHelperSQL.SetConnectionString("");
                List <Dictionary <string, object> > newAddedList = Grid1.GetNewAddedList();
                string lastcode = "", lastname = "";
                for (int i = 0; i < newAddedList.Count; i++)
                {
                    if (lastcode == newAddedList[i]["ClassCode"].ToString() || lastname == newAddedList[i]["ClassName"].ToString())
                    {
                        Alert.Show("第" + (i + 1) + "行已经存在相同的分类代码或分类名称,请更改");
                        return;
                    }
                    else
                    {
                        sql = "select count(*) from GoodsClass where ClassCode='" + newAddedList[i]["ClassCode"].ToString() + "' or  ClassName='" + newAddedList[i]["ClassName"].ToString() + "'";

                        if (int.Parse(SQLHelper.DbHelperSQL.GetSingle(sql, 30)) > 0)
                        {
                            Alert.Show("第" + (i + 1) + "行已经存在相同的分类代码或分类名称,请更改");
                            return;
                        }
                    }
                    lastcode = newAddedList[i]["ClassCode"].ToString();
                    lastname = newAddedList[i]["ClassName"].ToString();
                    sql      = "insert into GoodsClass(ClassCode,ClassName,SortIndex) values('" + newAddedList[i]["ClassCode"].ToString() + "','" + newAddedList[i]["ClassName"].ToString() + "'," + newAddedList[i]["SortIndex"].ToString() + ")";
                    log.Info("sql add GoodsClass:" + sql);
                    al.Add(sql);
                }

                //Alert.Show(s);
                //return;
                //s = "";
                // 修改的现有数据
                Dictionary <int, Dictionary <string, object> > modifiedDict = Grid1.GetModifiedDict();

                foreach (int rowIndex in modifiedDict.Keys)
                {
                    sql = "update GoodsClass set ";
                    for (int i = 0; i < Grid1.Columns.Count; i++)
                    {
                        if (modifiedDict[rowIndex].ContainsKey(Grid1.Columns[i].ColumnID))
                        {
                            sql += Grid1.Columns[i].ColumnID + "='" + modifiedDict[rowIndex][Grid1.Columns[i].ColumnID].ToString() + "',";
                        }
                    }
                    sql  = sql.TrimEnd(new char[] { ',' });
                    sql += " where sn=" + Grid1.DataKeys[rowIndex][0];

                    al.Add(sql);
                }


                SQLHelper.DbHelperSQL.SetConnectionString("");
                if (SQLHelper.DbHelperSQL.ExecuteSqlTran(al))
                {
                    Alert.Show("保存成功");
                    BindGrid();
                }
                else
                {
                    Alert.Show("保存失败");
                }
            }
            catch (Exception ee)
            {
                Alert.Show(ee.Message);
            }
        }
예제 #26
0
        /// <summary>
        ///     AddListGrid
        /// </summary>
        private void AddListGrid()
        {
            //新增行事件
            var dictList = Grid1.GetNewAddedList();

            foreach (var rowKey in dictList)
            {
                var sKeys   = new StringBuilder();
                var sValues = new StringBuilder();
                foreach (var key in rowKey.Keys)
                {
                    sKeys.AppendFormat("{0},", key);
                }

                foreach (var dictValue in rowKey.Values)
                {
                    sValues.AppendFormat("{0},", dictValue);
                }

                var keys   = sKeys.ToString().Split(',');
                var values = sValues.ToString().Split(',');

                var details = new LHDispatchCommissionDetails();

                for (int i = 0; i < keys.Count(); i++)
                {
                    #region 修改内容

                    var key   = keys[i];
                    var value = values[i];

                    if (!string.IsNullOrEmpty(key))
                    {
                        if (details != null)
                        {
                            if (key.Equals("KeyId"))
                            {
                                details.KeyId = value;
                            }

                            if (key.Equals("FDate"))
                            {
                                details.FDate = Convert.ToDateTime(value);
                            }
                            if (key.Equals("FCode"))
                            {
                                details.FCode = value;
                            }
                            if (key.Equals("FName"))
                            {
                                details.FName = value;
                            }

                            if (key.Equals("FArea"))
                            {
                                details.FArea = value;
                            }

                            if (key.Equals("FItemName"))
                            {
                                details.FItemName = value;
                            }

                            if (key.Equals("FQty"))
                            {
                                details.FQty = Convert.ToInt32(value);
                            }

                            if (key.Equals("FPrice"))
                            {
                                details.FPrice = Convert.ToDecimal(value);
                            }

                            if (key.Equals("FDriver"))
                            {
                                details.FDriver = value;
                            }

                            if (key.Equals("FDriverPrice"))
                            {
                                details.FDriverPrice = Convert.ToDecimal(value);
                            }
                            if (key.Equals("FSupercargo"))
                            {
                                details.FSupercargo = value;
                            }
                            if (key.Equals("FSupercargoPrice"))
                            {
                                details.FSupercargoPrice = Convert.ToDecimal(value);
                            }
                            if (key.Equals("FVehicleNum"))
                            {
                                details.FVehicleNum = value;
                            }

                            if (key.Equals("FMemo"))
                            {
                                details.FMemo = value;
                            }
                        }
                    }

                    #endregion
                }


                details.FCompanyId = CurrentUser.AccountComId;
                StockOutDetailsService.Add(details);
            }

            Grid1.CommitChanges();
        }
예제 #27
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void Grid1_AfterEdit(object sender, GridAfterEditEventArgs e)
        {
            var addList = Grid1.GetNewAddedList();

            foreach (var add in addList)
            {
                var dictValues = add.Values;

                //商品代码
                var firstOrDefault = dictValues.First();

                if (firstOrDefault != null)
                {
                    DataSet dataSet = GasHelper.GetSalesItem(firstOrDefault.ToString(), CurrentUser.AccountComId);

                    DataTable table = dataSet.Tables[0];

                    if (table != null && table.Rows.Count > 0)
                    {
                        decimal price = GasHelper.GeSupplierPrice("",//
                                                                  table.Rows[0]["FItemCode"].ToString(), CurrentUser.AccountComId);

                        table.Rows[0]["FPrice"] = price;

                        var details = new LHStockOutDetails
                        {
                            FItemCode     = table.Rows[0]["FItemCode"].ToString(),
                            FPrice        = price,
                            FQty          = 1,
                            FAmount       = price,
                            FBottleQty    = 1,
                            FBottleOweQty = 0,
                            FCompanyId    = CurrentUser.AccountComId,
                            KeyId         = txtKeyId.Text.Trim(),
                            FBottle       = table.Rows[0]["FBottleCode"].ToString(),
                            FCateId       = Convert.ToInt32(table.Rows[0]["FId"].ToString())
                        };

                        switch (Actions)
                        {
                        case WebAction.Add:
                            break;

                        case WebAction.Edit:
                            //记录一下当前新增人操作内容
                            var detailslog = new LHStockOutDetails_Log
                            {
                                FUpdateBy     = CurrentUser.AccountName,
                                FUpdateDate   = DateTime.Now,
                                FItemCode     = table.Rows[0]["FItemCode"].ToString(),
                                FPrice        = price,
                                FQty          = 1,
                                FAmount       = price,
                                FBottleQty    = 1,
                                FBottleOweQty = 0,
                                FCompanyId    = CurrentUser.AccountComId,
                                KeyId         = txtKeyId.Text.Trim(),
                                FBottle       = table.Rows[0]["FBottleCode"].ToString(),
                                FStatus       = "新增",
                                FMemo         = string.Format(@"时间:{0} 新增人:{1}", DateTime.Now, CurrentUser.AccountName)
                            };

                            //detailslog.FCompanyId = CurrentUser.AccountComId;
                            //detailslog.FCateId = Convert.ToInt32(table.Rows[0]["FId"].ToString());

                            StockOutDetailsLogService.Add(detailslog);

                            break;
                        }


                        StockOutDetailsService.Add(details);
                    }
                }
            }

            if (addList.Count > 0)
            {
                BindDataGrid();
            }
        }
예제 #28
0
        private string checkInput()
        {
            string msg = "";

            //if (txt_qymc.Text.Trim() == "") msg += "请输入企业名称!";
            //if (drp_sd.SelectedValue.ToString() == "3304") msg += "请选择企业所属区域!";
            //if (drop_status.SelectedValue.ToString() == "0") msg += "请选择企业生产状态!";
            //if (drop_industry.SelectedValue.ToString() == "0") msg += "请选择企业所属行业!";
            //if (sGuid == string.Empty || sGuid == null)
            //{
            //    string checkstr = "select * from Enterprise where Name='" + txt_qymc.Text.Trim() + "'";
            //    DataSet dscheck = new MyDataOp().CreateDataSet(checkstr);
            //    if (dscheck != null)
            //        if (dscheck.Tables[0].Rows.Count > 0)
            //        {
            //            msg += "该企业已存在!";
            //        }
            //}
            //else
            //{
            //    string checkstr = "select * from Enterprise where Name='" + txt_qymc.Text.Trim() + "' and EnterpriseID!='" + sGuid + "'";
            //    DataSet dscheck = new MyDataOp().CreateDataSet(checkstr);
            //    if (dscheck != null)
            //        if (dscheck.Tables[0].Rows.Count > 0)
            //        {
            //            msg += "单位全称不能重复!";
            //        }

            //}
            int RID = DAL.User.GetUserID(txt_HandleMan.Text.Trim(), 4);

            if (RID == 0)
            {
                msg += "请选择正确的处置人!";
            }
            else
            {
                hf_HandelManID.Text = RID.ToString();
            }
            if (!string.IsNullOrEmpty(txt_Receiver.Text.Trim()))
            {
                int RID2 = DAL.User.GetUserID(txt_Receiver.Text.Trim(), 2);
                if (RID2 == 0)
                {
                    msg += "请选择正确的签收人!";
                }
                else
                {
                    hf_ReceiverID.Text = RID2.ToString();
                }
            }
            decimal PlanAmount = decimal.Parse(NB_Amount.Text.Trim());
            decimal Old        = 0;

            if (!string.IsNullOrEmpty(sGuid))
            {
                Entity.WasteToProduct ws = DAL.WasteToProduct.GetWasteToProduct(int.Parse(sGuid));
                Old = ws.FromAmount;
            }
            Entity.Pond pond     = DAL.Pond.GetPond(int.Parse(drop_Pond.SelectedValue.ToString()));
            decimal     capacity = pond.Capacity;
            decimal     used     = pond.Used;

            if (used + PlanAmount - Old > capacity)
            {
                msg += "罐池的剩余量不足,罐池的剩余量为" + (capacity - used).ToString() + "!";
            }
            #region 判断是否有重复项,暂时去掉
            //判断是否有重复项
            List <string> All3 = new List <string>();
            Hashtable     ht3  = new Hashtable();
            Dictionary <int, Dictionary <string, object> > modifiedDict3 = Grid1.GetModifiedDict();
            foreach (int rowIndex in modifiedDict3.Keys)
            {
                All3.Add(Grid1.DataKeys[rowIndex][1].ToString());
            }
            List <Dictionary <string, object> > newAddedList3 = Grid1.GetNewAddedList();
            for (int i = 0; i < newAddedList3.Count; i++)
            {
                All3.Add(newAddedList3[i]["WasteName"].ToString());
            }
            List <int> deletedRows3 = Grid1.GetDeletedList();
            foreach (int rowIndex in deletedRows3)
            {
                All3.Remove(Grid1.DataKeys[rowIndex][1].ToString());
            }
            for (int i = 0; i < All3.Count; i++)
            {
                if (ht3.ContainsKey(All3[i]))
                {
                    ht3[All3[i]] = int.Parse(ht3[All3[i]].ToString()) + 1;
                }
                else
                {
                    ht3.Add(All3[i], 1);
                }
            }
            IDictionaryEnumerator ie3 = ht3.GetEnumerator();
            while (ie3.MoveNext())
            {
                if (int.Parse(ie3.Value.ToString()) > 1)
                {
                    msg += "成品中出现重复项" + ie3.Key + "!";
                }
                //Console.WriteLine(ie.Key.ToString() + "记录条数:" + ie.Value);
            }
            #endregion

            #region 判断是否有重复的罐池,并判断污染物和罐池是否对应
            List <string> All = new List <string>();
            Hashtable     ht  = new Hashtable();
            Dictionary <int, Dictionary <string, object> > modifiedDict = Grid1.GetModifiedDict();
            foreach (int rowIndex in modifiedDict.Keys)
            {
                All.Add(Grid1.DataKeys[rowIndex][3].ToString());
                Entity.Pond ponda = DAL.Pond.GetPondByName(Grid1.DataKeys[rowIndex][3].ToString());
                if (Grid1.DataKeys[rowIndex][1].ToString() != ponda.WasteName)
                {
                    msg += Grid1.DataKeys[rowIndex][1].ToString() + "不能存入" + Grid1.DataKeys[rowIndex][3].ToString() + "!";
                }
            }
            List <Dictionary <string, object> > newAddedList = Grid1.GetNewAddedList();
            for (int i = 0; i < newAddedList.Count; i++)
            {
                All.Add(newAddedList[i]["Name"].ToString());
                Entity.Pond ponda = DAL.Pond.GetPondByName(newAddedList[i]["Name"].ToString());
                if (newAddedList[i]["WasteName"].ToString() != ponda.WasteName)
                {
                    msg += newAddedList[i]["WasteName"].ToString() + "不能存入" + newAddedList[i]["Name"].ToString() + "!";
                }
            }
            List <int> deletedRows = Grid1.GetDeletedList();
            foreach (int rowIndex in deletedRows)
            {
                All.Remove(Grid1.DataKeys[rowIndex][3].ToString());
            }
            for (int i = 0; i < All.Count; i++)
            {
                if (ht.ContainsKey(All[i]))
                {
                    ht[All[i]] = int.Parse(ht[All[i]].ToString()) + 1;
                }
                else
                {
                    ht.Add(All[i], 1);
                }
            }
            IDictionaryEnumerator ie = ht.GetEnumerator();
            while (ie.MoveNext())
            {
                if (int.Parse(ie.Value.ToString()) > 1)
                {
                    msg += "成品中出现重复罐池" + ie.Key.ToString() + "!";
                }
                //Console.WriteLine(ie.Key.ToString() + "记录条数:" + ie.Value);
            }
            #endregion

            #region 判断危废是否重复
            //判断是否有重复项
            //List<string> All2 = new List<string>();
            //Hashtable ht2 = new Hashtable();
            //Dictionary<int, Dictionary<string, object>> modifiedDict2 = Grid2.GetModifiedDict();
            //foreach (int rowIndex in modifiedDict2.Keys)
            //{
            //    All2.Add(Grid2.DataKeys[rowIndex][1].ToString());
            //}
            //List<Dictionary<string, object>> newAddedList2 = Grid2.GetNewAddedList();
            //for (int i = 0; i < newAddedList2.Count; i++)
            //{
            //    All2.Add(newAddedList2[i]["WasteName2"].ToString());
            //}
            //List<int> deletedRows2 = Grid2.GetDeletedList();
            //foreach (int rowIndex in deletedRows2)
            //{
            //    All2.Remove(Grid2.DataKeys[rowIndex][1].ToString());
            //}
            //for (int i = 0; i < All2.Count; i++)
            //{
            //    if (ht2.ContainsKey(All2[i]))
            //    {
            //        ht2[All2[i]] = int.Parse(ht2[All2[i]].ToString()) + 1;
            //    }
            //    else
            //    {
            //        ht2.Add(All2[i], 1);
            //    }
            //}
            //IDictionaryEnumerator ie2 = ht2.GetEnumerator();
            //while (ie2.MoveNext())
            //{
            //    if (int.Parse(ie2.Value.ToString()) > 1)
            //    {
            //        msg += "危废中出现重复项"+ie2.Key+"!";
            //    }
            //    //Console.WriteLine(ie.Key.ToString() + "记录条数:" + ie.Value);
            //}

            #endregion

            return(msg);
        }
예제 #29
0
        protected void btnSend_Click(object sender, EventArgs e)
        {
            string mark = GetQueryValue("mark");

            List <Dictionary <string, object> > newAddedList = Grid1.GetNewAddedList();

            if (newAddedList.Count == 0)
            {
                ShowNotify("没有要提交的数据");
                return;
            }

            StockHeader stockHeader = new StockHeader();

            if (mark == "02")
            {
                stockHeader.title = "委外进货单";
            }
            else if (mark == "03")
            {
                stockHeader.title = "委外出货单";
            }

            stockHeader.optdate = DateTime.Now;
            //执行存储过程获取流水号
            SQLHelper.DbHelperSQL.SetConnectionString("");
            object[]  obj              = new object[] { "WW" };
            DataTable dt               = SQLHelper.DbHelperSQL.ExecuteProc_ReturnDataTable("GetSeq", obj, 10);
            string    prosn            = dt.Rows[0][0].ToString();
            string    StockHeaderProsn = "WW" + prosn;

            ShowNotify(StockHeaderProsn);
            stockHeader.StockHeaderProsn = StockHeaderProsn;
            stockHeader.jingbanren       = GetChineseName();

            MYDB.StockHeaders.Add(stockHeader);

            for (int i = 0; i < newAddedList.Count; i++)
            {
                SendOutStockList item = new SendOutStockList();
                item.Barcode = newAddedList[i]["barcode"].ToString();

                //订单号
                item.StockOrderNo = newAddedList[i]["saleno"].ToString();

                item.SendOutOrderNo = newAddedList[i]["orderno"].ToString();
                item.ItemNo         = newAddedList[i]["itemno"].ToString();
                item.ProNo          = newAddedList[i]["prono"].ToString();
                item.ItemName       = newAddedList[i]["itemname"].ToString();
                item.Spec           = newAddedList[i]["spec"].ToString();

                item.Quantity = decimal.Parse(newAddedList[i]["qut"].ToString());
                item.Space    = newAddedList[i]["space"].ToString();
                item.Remark   = newAddedList[i]["remark"].ToString();
                if (mark == "02")
                {
                    item.SendOutProperties = SendOutProperties.委外入库;
                }
                else
                {
                    item.SendOutProperties = SendOutProperties.委外出库;
                }

                item.Mark             = mark;
                item.Unit             = newAddedList[i]["unit"].ToString();
                item.PDate            = DateTime.Now;
                item.StockHeaderProsn = StockHeaderProsn;

                MYDB.SendOutStockLists.Add(item);
            }
            MYDB.SaveChanges();

            ShowNotify("提交成功");

            //清除页面数据
            PageContext.RegisterStartupScript("clearLocalStorage()");
        }
예제 #30
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            try
            {
                if (Grid1.GetModifiedData().Count == 0 && Grid1.GetNewAddedList().Count == 0)
                {
                    Alert.Show("表格数据没有变化!");
                    return;
                }
                ArrayList al = new ArrayList();
                string    sql = "", s = "";
                // 新增数据
                //List<Dictionary<string, object>> newAddedList = Grid1.GetNewAddedList();
                //for (int i = 0; i < newAddedList.Count; i++)
                //{
                //    //s += newAddedList[i]["ItemNo"].ToString() + "----" + newAddedList[i]["Name"].ToString() + "----" + newAddedList[i]["Spec"].ToString() + "----" + newAddedList[i]["MaterialNo"].ToString() + "----" + newAddedList[i]["ItemColor"].ToString();
                //    sql = "insert into AllItem(ItemNo,Name,Spec,MaterialNo,ItemColor,AddReserve1,ClassName) values('" + newAddedList[i]["ItemNo"].ToString() + "','" + newAddedList[i]["Name"].ToString() + "','" + newAddedList[i]["Spec"].ToString() + "','" + newAddedList[i]["MaterialNo"].ToString() + "','" + newAddedList[i]["ItemColor"].ToString() + "','" + newAddedList[i]["AddReserve1"].ToString() + "','" + newAddedList[i]["ClassName"].ToString() + "')";
                //    s += sql + "---";
                //    al.Add(sql);
                //}

                //Alert.Show(s);
                //return;
                //s = "";
                // 修改的现有数据
                Dictionary <int, Dictionary <string, object> > modifiedDict = Grid1.GetModifiedDict();
                SQLHelper.DbHelperSQL.SetConnectionString("");
                foreach (int rowIndex in modifiedDict.Keys)
                {
                    sql = "update Instruction set ";
                    for (int i = 0; i < Grid1.Columns.Count; i++)
                    {
                        if (modifiedDict[rowIndex].ContainsKey(Grid1.Columns[i].ColumnID))
                        {
                            sql += Grid1.Columns[i].ColumnID + "='" + modifiedDict[rowIndex][Grid1.Columns[i].ColumnID].ToString() + "',";
                        }
                    }
                    //sql = sql.TrimEnd(new char[] { ',' });
                    sql += "ConfirmDate=getdate() where sn=" + Grid1.DataKeys[rowIndex][0];

                    al.Add(sql);
                    sql = "select case  when (select COUNT(*) from Instruction where OdtSN = " + Grid1.Rows[rowIndex].Values[21].ToString() + "  and OrderNo = '" + Grid1.Rows[rowIndex].Values[1].ToString() + "') >= (select COUNT(*) from BomDetail where FSN = (select SN from BomHeader where OdtSN = " + Grid1.Rows[rowIndex].Values[21].ToString() + " and OrderNo = '" + Grid1.Rows[rowIndex].Values[1].ToString() + "')) then 1 else 0 end ";

                    if (SQLHelper.DbHelperSQL.GetSingle(sql, 30) == "1")
                    {
                        sql = "update OrderDetail set isconfirm=1 where SN = " + Grid1.Rows[rowIndex].Values[21].ToString() + "  and OrderNo = '" + Grid1.Rows[rowIndex].Values[1].ToString() + "'";
                        al.Add(sql);
                        //Alert.Show(sql);
                    }
                }



                SQLHelper.DbHelperSQL.SetConnectionString("");
                if (SQLHelper.DbHelperSQL.ExecuteSqlTran(al))
                {
                    Alert.Show("保存成功");
                    BindGrid();
                }
                else
                {
                    Alert.Show("保存失败");
                }
            }
            catch (Exception ee)
            {
                Alert.Show(ee.Message);
            }
        }