Esempio n. 1
0
        protected void btnDeleteSelected_Click(object sender, EventArgs e)
        {
            // 删除新增未保存到数据库的数据
            List <int> deletedRows = Grid1.GetDeletedList();

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

            // 在操作之前进行权限检查
            if (!CheckPower("GoodsClassDelete"))
            {
                CheckPowerFailWithAlert();
                return;
            }

            // 从每个选中的行中获取ID(在Grid1中定义的DataKeyNames)
            List <int> ids = GetSelectedDataKeyIDs(Grid1);

            // 执行数据库操作
            //DB.Users.Where(u => ids.Contains(u.UserID)).ToList().ForEach(u => DB.Users.Remove(u));
            //DB.SaveChanges();
            if (ids.Count > 0)
            {
                using (var appdb = new AppContext())
                {
                    appdb.goodsclass.Where(u => ids.Contains(u.SN)).Delete();
                }
            }
            // 重新绑定表格
            BindGrid();
        }
Esempio n. 2
0
        protected void btnDeleteSelected_Click(object sender, EventArgs e)
        {
            // 删除新增未保存到数据库的数据
            List <int> deletedRows = Grid1.GetDeletedList();

            if (deletedRows != null && Grid1.GetDeletedList().Count != 0)
            {
                foreach (int rowIndex in deletedRows)
                {
                    //int rowID = Convert.ToInt32(Grid1.DataKeys[rowIndex][0]);
                    Grid1.Rows.RemoveAt(rowIndex);
                }
            }
            int[] selectrows = Grid1.SelectedRowIndexArray;
            foreach (int rowindex in selectrows)
            {
                if (Grid1.Rows[rowindex].Values[11].ToString() == "1")
                {
                    Alert.Show("第" + (rowindex + 1) + "行订单已审核通过不能删除");
                    return;
                }
            }
            // 在操作之前进行权限检查
            if (!CheckPower("OrderDelete"))
            {
                CheckPowerFailWithAlert();
                return;
            }

            // 从每个选中的行中获取ID(在Grid1中定义的DataKeyNames)
            List <int> ids = GetSelectedDataKeyIDs(Grid1);

            // 执行数据库操作
            //DB.Users.Where(u => ids.Contains(u.UserID)).ToList().ForEach(u => DB.Users.Remove(u));
            //DB.SaveChanges();
            if (ids.Count > 0)
            {
                using (var appdb = new AppContext())
                {
                    if (appdb.orderdetail.Where(u => ids.Contains(u.FSN) && u.IsBom == 1).Count() > 0)
                    {
                        Alert.Show("订单中已有生成BOM的产品,无法删除订单");
                        return;
                    }

                    appdb.orderdetail.Where(u => ids.Contains(u.FSN)).Delete();
                    appdb.orderheader.Where(u => ids.Contains(u.SN)).Delete();
                }
            }
            // 重新绑定表格
            BindGrid();
            BindGrid2();
        }
Esempio n. 3
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("数据保存成功!(表格数据已重新绑定)");
        }
Esempio n. 4
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
        }
Esempio n. 5
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);
        }
Esempio n. 6
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.Analysis entity = new Entity.Analysis();
                    entity.BillNumber    = txt_BillNumber.Text.Trim();
                    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      = Date.SelectedDate;
                    entity.AnalysisManID = int.Parse(hf_AnalysisID.Text.Trim());
                    entity.Status        = 1;

                    if (string.IsNullOrEmpty(sGuid))
                    {
                        //Add


                        //List<Entity.AnalysisResult> results = new List<Entity.AnalysisResult>();
                        //foreach (GridRow gr in Grid1.Rows)
                        //{
                        //    Entity.AnalysisResult result = new Entity.AnalysisResult();
                        //    result.ItemCode = DAL.AnalysisItem.GetItemCodeByName(gr.DataKeys[2].ToString());
                        //    result.Result = decimal.Parse(gr.DataKeys[3].ToString());
                        //    results.Add(result);
                        //}
                        List <Dictionary <string, object> > newAddedList = Grid1.GetNewAddedList();
                        List <Entity.AnalysisResult>        Adds         = new List <Entity.AnalysisResult>();
                        for (int i = 0; i < newAddedList.Count; i++)
                        {
                            Entity.AnalysisResult add = new Entity.AnalysisResult();
                            add.Result   = decimal.Parse(newAddedList[i]["Result"].ToString());
                            add.ItemCode = DAL.AnalysisItem.GetItemCodeByName(newAddedList[i]["ItemName"].ToString());
                            Adds.Add(add);
                        }
                        iReturn = DAL.Analysis.AddAnalysisEntity(entity, Adds);

                        //iReturn = DAL.Analysis.AddAnalysisEntity(entity, results);
                    }
                    else
                    {
                        //Update
                        entity.AnalysisID = int.Parse(sGuid);
                        List <int> deletedRows = Grid1.GetDeletedList();
                        List <Entity.AnalysisResult> Deletes = new List <Entity.AnalysisResult>();
                        foreach (int rowIndex in deletedRows)
                        {
                            Entity.AnalysisResult delete = new Entity.AnalysisResult();
                            delete.ResultID = Convert.ToInt32(Grid1.DataKeys[rowIndex][0]);
                            Deletes.Add(delete);
                        }


                        Dictionary <int, Dictionary <string, object> > modifiedDict = Grid1.GetModifiedDict();
                        List <Entity.AnalysisResult> Updates = new List <Entity.AnalysisResult>();
                        foreach (int rowIndex in modifiedDict.Keys)
                        {
                            Entity.AnalysisResult update = new Entity.AnalysisResult();
                            update.ResultID = Convert.ToInt32(Grid1.DataKeys[rowIndex][0]);
                            update.ItemCode = DAL.AnalysisItem.GetItemCodeByName(Grid1.DataKeys[rowIndex][1].ToString());
                            update.Result   = decimal.Parse(Grid1.DataKeys[rowIndex][2].ToString());
                            Updates.Add(update);
                        }

                        List <Dictionary <string, object> > newAddedList = Grid1.GetNewAddedList();
                        List <Entity.AnalysisResult>        Adds         = new List <Entity.AnalysisResult>();
                        for (int i = 0; i < newAddedList.Count; i++)
                        {
                            Entity.AnalysisResult add = new Entity.AnalysisResult();
                            add.Result   = decimal.Parse(newAddedList[i]["Result"].ToString());
                            add.ItemCode = DAL.AnalysisItem.GetItemCodeByName(newAddedList[i]["ItemName"].ToString());
                            Adds.Add(add);
                        }
                        iReturn = DAL.Analysis.UpdateAnalysisEntity(entity, Adds, Deletes, Updates);
                    }
                }
                catch (Exception ex)
                {
                }
                finally
                {
                }
                if (iReturn == 1)
                {
                    Alert.ShowInTop(" 保存成功!", MessageBoxIcon.Information);
                    //            PageContext.RegisterStartupScript(ActiveWindow.GetHidePostBackReference());
                }
                else
                {
                    Alert.ShowInTop(" 保存失败!", MessageBoxIcon.Warning);
                }
            }
            #endregion
        }
Esempio n. 7
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 WSID = 0;

            if (!string.IsNullOrEmpty(txt_BillNumber.Text.Trim()))
            {
                WSID = DAL.WasteStorage.GetWasteStorageIDByBillNumber(txt_BillNumber.Text);
                if (WSID == 0)
                {
                    msg += "请选择正确的联单编号!";
                }
                else
                {
                    DataTable dt = DAL.Analysis.GetAnalysis(txt_BillNumber.Text, "", "", -2);
                    if (!string.IsNullOrEmpty(sGuid))
                    {
                        if (dt.Rows[0]["AnalysisID"].ToString() != sGuid)
                        {
                            msg += "此联单编号已存在分析信息!";
                        }
                    }
                    else
                    {
                        if (dt.Rows.Count > 0)
                        {
                            msg += "此联单编号已存在分析信息!";
                        }
                    }
                }
                //else
                //{
                //    hf_PlanID.Text = PlanID.ToString();
                //}
            }

            int RID = DAL.User.GetUserID(txt_Analysis.Text.Trim(), 1);

            if (RID == 0)
            {
                msg += "请选择正确的分析人!";
            }
            else
            {
                hf_AnalysisID.Text = RID.ToString();
            }
            //判断是否有重复项
            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][1].ToString());
            }
            List <Dictionary <string, object> > newAddedList = Grid1.GetNewAddedList();

            for (int i = 0; i < newAddedList.Count; i++)
            {
                All.Add(newAddedList[i]["ItemName"].ToString());
            }
            List <int> deletedRows = Grid1.GetDeletedList();

            foreach (int rowIndex in deletedRows)
            {
                All.Remove(Grid1.DataKeys[rowIndex][1].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 += "分析项中出现重复项!";
                }
                //Console.WriteLine(ie.Key.ToString() + "记录条数:" + ie.Value);
            }

            //List<string> Add = new List<string>();
            //List<string> Add2 = new List<string>();
            //List<string> Update = new List<string>();



            //for (int i = 0; i < Add2.Count; i++)  //外循环是循环的次数
            //{
            //    for (int j = Add2.Count - 1; j > i; j--)  //内循环是 外循环一次比较的次数
            //    {

            //        if (Add2[i] == Add2[j])
            //        {
            //            Add2.RemoveAt(j);
            //        }

            //    }
            //}
            //if (Add.Count > Add2.Count)
            //{
            //    msg += "分析项中出现重复项!";
            //}

            //for (int i = 0; i < newAddedList.Count; i++)
            //{
            //    Add.Add(newAddedList[i]["ItemName"].ToString());
            //}
            //foreach (string s in Add)
            //{
            //    if (Update.Contains(s))
            //    {
            //        msg += "分析项中出现多个"+s+"!";
            //    }
            //}
            return(msg);
        }
Esempio n. 8
0
        private string checkInput()
        {
            string msg = "";

            int RID = DAL.User.GetUserID(txt_Analysis.Text.Trim(), 1);

            if (RID == 0)
            {
                msg += "请选择正确的分析人!";
            }
            else
            {
                hf_AnalysisID.Text = RID.ToString();
            }
            //判断是否有重复项
            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][1].ToString());
            }
            List <Dictionary <string, object> > newAddedList = Grid1.GetNewAddedList();

            for (int i = 0; i < newAddedList.Count; i++)
            {
                All.Add(newAddedList[i]["ItemName"].ToString());
            }
            List <int> deletedRows = Grid1.GetDeletedList();

            foreach (int rowIndex in deletedRows)
            {
                All.Remove(Grid1.DataKeys[rowIndex][1].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 += "监测项中出现重复项!";
                }
                //Console.WriteLine(ie.Key.ToString() + "记录条数:" + ie.Value);
            }

            //List<string> Add = new List<string>();
            //List<string> Add2 = new List<string>();
            //List<string> Update = new List<string>();



            //for (int i = 0; i < Add2.Count; i++)  //外循环是循环的次数
            //{
            //    for (int j = Add2.Count - 1; j > i; j--)  //内循环是 外循环一次比较的次数
            //    {

            //        if (Add2[i] == Add2[j])
            //        {
            //            Add2.RemoveAt(j);
            //        }

            //    }
            //}
            //if (Add.Count > Add2.Count)
            //{
            //    msg += "分析项中出现重复项!";
            //}

            //for (int i = 0; i < newAddedList.Count; i++)
            //{
            //    Add.Add(newAddedList[i]["ItemName"].ToString());
            //}
            //foreach (string s in Add)
            //{
            //    if (Update.Contains(s))
            //    {
            //        msg += "分析项中出现多个"+s+"!";
            //    }
            //}
            return(msg);
        }