Пример #1
0
        public MixMaterialGroup_mmpg_Info DisplayRecord(IModelObject KeyObject)
        {
            MixMaterialGroup_mmpg_Info info = new MixMaterialGroup_mmpg_Info();

            using (MainDBDataContext db = new MainDBDataContext())
            {
                MixMaterialGroup_mmpg disTab = db.MixMaterialGroup_mmpg.SingleOrDefault(t => t.mmpg_Id == ((KeyObject) as MixMaterialGroup_mmpg_Info).mmpg_Id);
                if (disTab != null)
                {
                    info = Common.General.CopyObjectValue<MixMaterialGroup_mmpg, MixMaterialGroup_mmpg_Info>(disTab);
                }
            }

            return info;
        }
Пример #2
0
        public bool InsertRecord(MixMaterialGroup_mmpg_Info infoObject)
        {
            bool isSuccess = false;
            MixMaterialGroup_mmpg_Info info = new MixMaterialGroup_mmpg_Info();
            info = infoObject;

            using (MainDBDataContext db = new MainDBDataContext())
            {
                MixMaterialGroup_mmpg newTab = Common.General.CopyObjectValue<MixMaterialGroup_mmpg_Info, MixMaterialGroup_mmpg>(infoObject);
                db.MixMaterialGroup_mmpg.InsertOnSubmit(newTab);
                db.SubmitChanges();
                isSuccess = true;
            }

            return isSuccess;
        }
Пример #3
0
        public bool DeleteRecord(IModelObject KeyObject)
        {
            bool isSuccess = false;
            MixMaterialGroup_mmpg_Info info = new MixMaterialGroup_mmpg_Info();
            info = KeyObject as MixMaterialGroup_mmpg_Info;

            using (MainDBDataContext db = new MainDBDataContext())
            {
                MixMaterialGroup_mmpg delTab = db.MixMaterialGroup_mmpg.SingleOrDefault(t => t.mmpg_Id == info.mmpg_Id);
                if (delTab != null)
                {
                    db.MixMaterialGroup_mmpg.DeleteOnSubmit(delTab);
                    db.SubmitChanges();
                    isSuccess = true;
                }
            }
            return isSuccess;
        }
Пример #4
0
 public ReturnValueInfo Save_SQL(IModelObject itemEntity, DefineConstantValue.EditStateEnum EditMode)
 {
     ReturnValueInfo returnValue = new ReturnValueInfo();
     MixMaterialGroup_mmpg_Info info = new MixMaterialGroup_mmpg_Info();
     returnValue.messageText = "";
     info = itemEntity as MixMaterialGroup_mmpg_Info;
     try
     {
         switch (EditMode)
         {
             case Common.DefineConstantValue.EditStateEnum.OE_Insert:
                 bool isExist = false;
                 isExist = _MixMaterialGroupSQL.IsExistRecord(info);
                 if (!isExist)
                 {
                     returnValue.boolValue = _MixMaterialGroupSQL.InsertRecord(info);
                 }
                 else
                 {
                     returnValue.boolValue = false;
                     returnValue.messageText = "數據重複!";
                 }
                 break;
             case Common.DefineConstantValue.EditStateEnum.OE_Update:
                 returnValue.boolValue = _MixMaterialGroupSQL.UpdateRecord(info);
                 break;
             case Common.DefineConstantValue.EditStateEnum.OE_Delete:
                 returnValue.boolValue = _MixMaterialGroupSQL.DeleteRecord(info);
                 break;
         }
     }
     catch (Exception Ex)
     {
         throw Ex;
     }
     return returnValue;
 }
Пример #5
0
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);

            BindData();

            if (this.EditState == Common.DefineConstantValue.EditStateEnum.OE_Insert)
            {
                this.TabText = "新增 - " + this.Text;
                //this._tmpobjInfo = new MaterialProfile_mlpf_Info();
                this.sysToolBar.BtnSave_IsUsed = true;
                this.sysToolBar.BtnSave_IsEnabled = true;

            }
            else if (this.EditState == Common.DefineConstantValue.EditStateEnum.OE_Update)
            {
                this.TabText = "编辑 - " + this.Text;
                if (base.BaseParam != null)
                {
                    MixMaterialGroup_mmpg_Info objInfo = this.BaseParam as MixMaterialGroup_mmpg_Info;
                    this._tmpGroup = objInfo;

                    txtCode.Enabled = false;
                    txtCode.Text = this._tmpGroup.mmpg_cMaterialGroupNo;
                    txtName.Text = this._tmpGroup.mmpg_cMaterialGroupName;

                    ShowDetail();
                }
                else
                {
                    this.ShowWarningMessage("没有可用的记录。");
                }
                this.sysToolBar.BtnSave_IsUsed = true;
                this.sysToolBar.BtnSave_IsEnabled = true;
            }
            else if (this.EditState == Common.DefineConstantValue.EditStateEnum.OE_ReaOnly)
            {
                this.TabText = "查看 - " + this.Text;
                if (base.BaseParam != null)
                {
                    MixMaterialGroup_mmpg_Info objInfo = this.BaseParam as MixMaterialGroup_mmpg_Info;
                    this._tmpGroup = objInfo;

                    txtCode.Text = this._tmpGroup.mmpg_cMaterialGroupNo;
                    txtName.Text = this._tmpGroup.mmpg_cMaterialGroupName;

                    ShowDetail();
                }
                else
                {
                    this.ShowWarningMessage("没有可用的记录。");
                }
                this.sysToolBar.BtnSave_IsUsed = false;
            }

            this.sysToolBar.BtnExit_IsEnabled = true;
            this.sysToolBar.BtnExit_IsUsed = true;

            this.sysToolBar.BtnDelete_IsEnabled = false;
            //btnAdd.Enabled = false;
            btnSave.Enabled = false;

            SetLV(lstViewMaterial, true);
            SetLV(lstViewGroupDetail, false);
        }
Пример #6
0
        void GetObjInfo()
        {
            _tmpDetail = new List<MixMaterialDetail_mmdl_Info>();
            if (this.EditState == Common.DefineConstantValue.EditStateEnum.OE_Insert)
            {
                _tmpGroup = new MixMaterialGroup_mmpg_Info() { mmpg_Id = Guid.NewGuid() };
                _tmpGroup.mmpg_cAdd = base.UserInformation.usm_cUserLoginID;
                _tmpGroup.mmpg_dAddDate = DateTime.Now;
                _tmpGroup.mmpg_cLast = base.UserInformation.usm_cUserLoginID;
                _tmpGroup.mmpg_dLastDate = DateTime.Now;
            }
            _tmpGroup.mmpg_cMaterialGroupNo = txtCode.Text;
            _tmpGroup.mmpg_cMaterialGroupName = txtName.Text;

            if (lstViewGroupDetail.Items.Count > 0)
            {
                MixMaterialDetail_mmdl_Info tmpDetail;
                foreach (ListViewItem item in lstViewGroupDetail.Items)
                {
                    tmpDetail = new MixMaterialDetail_mmdl_Info() { mmdl_Id = Guid.NewGuid() };
                    tmpDetail.mmdl_cMaterialGroupNo = txtCode.Text;
                    tmpDetail.mmdl_cMaterialCode = item.SubItems[2].Text;
                    tmpDetail.mmdl_fMaterialProportion = Convert.ToDecimal(item.SubItems[1].Text);

                    _tmpDetail.Add(tmpDetail);
                }
            }
        }
Пример #7
0
        /// <summary>
        /// 物料群組主檔
        /// </summary>
        public List<MixMaterialGroup_mmpg_Info> GetMixMaterialGroupMaster()
        {
            try
            {
                List<MixMaterialGroup_mmpg_Info> list = new List<MixMaterialGroup_mmpg_Info>();
                StringBuilder strSql = new StringBuilder();
                strSql.AppendLine("select   ");
                strSql.AppendLine(" mmpg_Id,mmpg_cMaterialGroupNo,mmpg_cMaterialGroupName,mmpg_cAdd,mmpg_dAddDate,mmpg_cLast,mmpg_dLastDate ");
                strSql.AppendLine(" from MixMaterialGroup_mmpg ");

                using (SqlDataReader sdr = DbHelperSQL.ExecuteReader(strSql.ToString()))
                {
                    while (sdr.Read())
                    {
                        MixMaterialGroup_mmpg_Info model = new MixMaterialGroup_mmpg_Info();
                        if (sdr["mmpg_Id"] != null && sdr["mmpg_Id"].ToString() != "")
                        {
                            model.mmpg_Id = new Guid(sdr["mmpg_Id"].ToString());
                        }
                        if (sdr["mmpg_cMaterialGroupNo"] != null && sdr["mmpg_cMaterialGroupNo"].ToString() != "")
                        {
                            model.mmpg_cMaterialGroupNo = sdr["mmpg_cMaterialGroupNo"].ToString();
                        }
                        if (sdr["mmpg_cMaterialGroupName"] != null && sdr["mmpg_cMaterialGroupName"].ToString() != "")
                        {
                            model.mmpg_cMaterialGroupName = sdr["mmpg_cMaterialGroupName"].ToString();
                        }
                        if (sdr["mmpg_cAdd"] != null && sdr["mmpg_cAdd"].ToString() != "")
                        {
                            model.mmpg_cAdd = sdr["mmpg_cAdd"].ToString();
                        }
                        if (sdr["mmpg_dAddDate"] != null && sdr["mmpg_dAddDate"].ToString() != "")
                        {
                            model.mmpg_dAddDate = DateTime.Parse(sdr["mmpg_dAddDate"].ToString());
                        }
                        if (sdr["mmpg_cLast"] != null && sdr["mmpg_cLast"].ToString() != "")
                        {
                            model.mmpg_cLast = sdr["mmpg_cLast"].ToString();
                        }
                        if (sdr["mmpg_dLastDate"] != null && sdr["mmpg_dLastDate"].ToString() != "")
                        {
                            model.mmpg_dLastDate = DateTime.Parse(sdr["mmpg_dLastDate"].ToString());
                        }
                        list.Add(model);
                    }
                }
                return list;
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Пример #8
0
 private string GetMixMaterialGroupMasterSQL(MixMaterialGroup_mmpg_Info model)
 {
     StringBuilder strSql = new StringBuilder();
     StringBuilder strSql1 = new StringBuilder();
     StringBuilder strSql2 = new StringBuilder();
     if (model.mmpg_Id != null)
     {
         strSql1.Append("mmpg_Id,");
         strSql2.Append("'" + model.mmpg_Id + "',");
     }
     if (model.mmpg_cMaterialGroupNo != null)
     {
         strSql1.Append("mmpg_cMaterialGroupNo,");
         strSql2.Append("'" + model.mmpg_cMaterialGroupNo + "',");
     }
     if (model.mmpg_cMaterialGroupName != null)
     {
         strSql1.Append("mmpg_cMaterialGroupName,");
         strSql2.Append("'" + model.mmpg_cMaterialGroupName + "',");
     }
     if (model.mmpg_cAdd != null)
     {
         strSql1.Append("mmpg_cAdd,");
         strSql2.Append("'" + model.mmpg_cAdd + "',");
     }
     if (model.mmpg_dAddDate != null)
     {
         strSql1.Append("mmpg_dAddDate,");
         strSql2.Append("'" + model.mmpg_dAddDate.Value.ToString(this._sqlLiteDatetimeFormat) + "',");
     }
     if (model.mmpg_cLast != null)
     {
         strSql1.Append("mmpg_cLast,");
         strSql2.Append("'" + model.mmpg_cLast + "',");
     }
     if (model.mmpg_dLastDate != null)
     {
         strSql1.Append("mmpg_dLastDate,");
         strSql2.Append("'" + model.mmpg_dLastDate.Value.ToString(this._sqlLiteDatetimeFormat) + "',");
     }
     strSql.Append("insert into MixMaterialGroup_mmpg(");
     strSql.Append(strSql1.ToString().Remove(strSql1.Length - 1));
     strSql.Append(")");
     strSql.Append(" values (");
     strSql.Append(strSql2.ToString().Remove(strSql2.Length - 1));
     strSql.Append(")");
     return strSql.ToString();
 }
Пример #9
0
        public List<MixMaterialGroup_mmpg_Info> SearchRecords(IModelObject searchCondition)
        {
            List<MixMaterialGroup_mmpg_Info> list = new List<MixMaterialGroup_mmpg_Info>();
            MixMaterialGroup_mmpg_Info info = new MixMaterialGroup_mmpg_Info();
            info = searchCondition as MixMaterialGroup_mmpg_Info;

            StringBuilder sqlString = new StringBuilder();

            sqlString.AppendLine("SELECT TOP " + Common.DefineConstantValue.ListRecordMaxCount.ToString());
            sqlString.AppendLine("*");
            sqlString.AppendLine("FROM MixMaterialGroup_mmpg ");

            sqlString.AppendLine("WHERE 1=1 --And mlpf_lIsDeleted=0");

            if (info.mmpg_cMaterialGroupNo != "" && info.mmpg_cMaterialGroupNo != null)
            {
                sqlString.AppendLine("AND mmpg_cMaterialGroupNo='" + info.mmpg_cMaterialGroupNo + "'");
            }

            if (info.mmpg_cMaterialGroupName != "" && info.mmpg_cMaterialGroupName != null)
            {
                sqlString.AppendLine("AND mmpg_cMaterialGroupName='" + info.mmpg_cMaterialGroupName + "'");
            }

            IEnumerable<MixMaterialGroup_mmpg_Info> infos = null;

            using (MainDBDataContext db = new MainDBDataContext())
            {
                infos = db.ExecuteQuery<MixMaterialGroup_mmpg_Info>(sqlString.ToString(), new object[] { });

                if (infos != null)
                {
                    list = infos.ToList<MixMaterialGroup_mmpg_Info>();
                }
            }

            return list;
        }
Пример #10
0
        public bool UpdateRecord(MixMaterialGroup_mmpg_Info infoObject)
        {
            bool isSuccess = false;

            using (MainDBDataContext db = new MainDBDataContext())
            {
                MixMaterialGroup_mmpg query = db.MixMaterialGroup_mmpg.SingleOrDefault(t => t.mmpg_Id == infoObject.mmpg_Id);
                if (query != null)
                {
                    query.mmpg_cMaterialGroupNo = infoObject.mmpg_cMaterialGroupNo;
                    query.mmpg_cMaterialGroupName = infoObject.mmpg_cMaterialGroupName;
                    query.mmpg_cLast = infoObject.mmpg_cLast;
                    query.mmpg_dLastDate = infoObject.mmpg_dLastDate;
                    //query.mlpf_lSync = infoObject.mlpf_lSync;
                    db.SubmitChanges();
                    isSuccess = true;
                }
            }

            return isSuccess;
        }