protected bool ImportFromExcelToDelete(DataSet ds)
        {
            try
            {
                System.Data.DataTable dt = ds.Tables[0];

                int nAll = dt.Rows.Count;
                int nDelete = 0;
                int nEmpty = 0;

                foreach (System.Data.DataRow dr in dt.Rows)
                {
                    if (dr["SelectX"].ToString().ToLower() == "x")
                    {
                        string PersonCode = dr["PersonCode"].ToString().Trim();

                        //判断是否存在
                        if (!KPI_PersonDal.PersonCodeExists(PersonCode, ""))
                        {
                            //MessageBox.popupClientMessage(this.Page, " 该机组的输出标签已存在!", "call();");
                            nEmpty += 1;
                            continue;
                        }
                        else
                        {
                            //main tag
                            //string RealID = KPI_PersonDal.GetRealID(PersonCode);

                            KPI_PersonEntity mEntity = new KPI_PersonEntity();
                            mEntity.PersonID = KPI_PersonDal.GetPersonID(PersonCode);

                            KPI_PersonDal.Delete(mEntity);
                            nDelete += 1;
                        }
                    }
                }

                string strInfor = "标签点总数为:{0}个, 删除成功:{1}个,空标签点: {2}个。";
                strInfor = string.Format(strInfor, nAll, nDelete, nEmpty);

                MessageBox.popupClientMessage(this.Page, strInfor, "call();");

                return true;

            }
            catch (Exception ee)
            {
                //
                MessageBox.popupClientMessage(this.Page, ee.Message, "call();");

                return false;
            }

        }
Пример #2
0
 /// <summary>
 /// 从界面获取对象
 /// </summary>
 /// <returns></returns>
 private KPI_PersonEntity GetPersonUI()
 {
     KPI_PersonEntity Result = new KPI_PersonEntity();
     Result.PersonID = PersonID;
     Result.PositionID = drpPositions.SelectedValue;
     Result.PersonCode = txtPersonCode.Text;
     Result.PersonName = txtPersonName.Text;
     Result.PersonDesc = txtPersonDesc.Text;
     Result.PersonIsValid = chkPersonIsValid.Checked?"1":"0";
     Result.PersonNote = txtPersonNote.Text;
     Result.UnitID = drpUnits.SelectedValue;
     Result.Shift = drpShifts.SelectedValue;
     Result.SpecialField = drpSpecialFields.SelectedValue;
     return Result;
 }
        protected bool ImportFromExcelToModify(DataSet ds)
        {
            try
            {
                System.Data.DataTable dt = ds.Tables[0];

                int nAll = dt.Rows.Count;
                int nModify = 0;
                int nNoExist = 0;

                foreach (System.Data.DataRow dr in dt.Rows)
                {
                    if (dr["SelectX"].ToString().ToLower() == "x")
                    {
                        string PersonCode = dr["PersonCode"].ToString().Trim();

                        //判断是否存在
                        if (!KPI_PersonDal.PersonCodeExists(PersonCode, ""))
                        {
                            //MessageBox.popupClientMessage(this.Page, " 该机组的输出标签已存在!", "call();");
                            nNoExist += 1;
                            continue;
                        }

                        //main tag
                        string keyid = KPI_PersonDal.GetPersonID(PersonCode);

                        KPI_PersonEntity mEntity = new KPI_PersonEntity();
                        mEntity.PersonID = keyid;
                        mEntity.PositionID = KPI_PositionDal.GetPositionID(dr["PositionName"].ToString().Trim());
                        mEntity.PersonCode = PersonCode;
                        mEntity.PersonName = dr["PersonName"].ToString().Trim();
                        mEntity.PersonDesc = dr["PersonDesc"].ToString().Trim();
                        mEntity.PersonIsValid = dr["PersonIsValid"].ToString().Trim();
                        mEntity.PersonNote = dr["PersonNote"].ToString().Trim();
                        
                        KPI_PersonDal.Update(mEntity);

                        nModify += 1;
                    }


                }

                string strInfor = "标签点总数为:{0}个, 修改成功:{1}个,不存在标签点: {2}个。";
                strInfor = string.Format(strInfor, nAll, nModify, nNoExist);

                MessageBox.popupClientMessage(this.Page, strInfor, "call();");

                return true;

            }
            catch (Exception ee)
            {
                //
                MessageBox.popupClientMessage(this.Page, ee.Message, "call();");

                return false;
            }
        }