Esempio n. 1
0
        public bool DeleteRecord(IModelObject KeyObject)
        {
            bool isSuccess = false;
            MixMaterialDetail_mmdl_Info info = new MixMaterialDetail_mmdl_Info();
            info = KeyObject as MixMaterialDetail_mmdl_Info;

            using (MainDBDataContext db = new MainDBDataContext())
            {
                MixMaterialDetail_mmdl delTab = null;
                if (info.mmdl_Id != new Guid())
                {
                    delTab = db.MixMaterialDetail_mmdl.SingleOrDefault(t => t.mmdl_Id == info.mmdl_Id);
                    if (delTab != null)
                    {
                        db.MixMaterialDetail_mmdl.DeleteOnSubmit(delTab);
                    }
                }
                else
                {
                    var del = db.MixMaterialDetail_mmdl.Where(t =>
                        (info.mmdl_cMaterialCode != null ? t.mmdl_cMaterialCode == info.mmdl_cMaterialCode : true)
                        && (info.mmdl_cMaterialGroupNo != null ? t.mmdl_cMaterialGroupNo == info.mmdl_cMaterialGroupNo : true)
                        );
                    db.MixMaterialDetail_mmdl.DeleteAllOnSubmit(del);
                }
                //if (info.mmdl_cMaterialGroupNo != null)
                //{
                //    var del = db.MixMaterialDetail_mmdl.Where(c => c.mmdl_cMaterialGroupNo == info.mmdl_cMaterialGroupNo);
                //    db.MixMaterialDetail_mmdl.DeleteAllOnSubmit(del);
                //}
                db.SubmitChanges();
                isSuccess = true;
            }
            return isSuccess;
        }
Esempio n. 2
0
        public MixMaterialDetail_mmdl_Info DisplayRecord(IModelObject KeyObject)
        {
            MixMaterialDetail_mmdl_Info info = new MixMaterialDetail_mmdl_Info();

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

            return info;
        }
Esempio n. 3
0
        public bool InsertRecord(MixMaterialDetail_mmdl_Info infoObject)
        {
            bool isSuccess = false;
            MixMaterialDetail_mmdl_Info info = new MixMaterialDetail_mmdl_Info();
            info = infoObject;

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

            return isSuccess;
        }
Esempio n. 4
0
 public ReturnValueInfo Save_SQL(IModelObject itemEntity, DefineConstantValue.EditStateEnum EditMode)
 {
     ReturnValueInfo returnValue = new ReturnValueInfo();
     MixMaterialDetail_mmdl_Info info = new MixMaterialDetail_mmdl_Info();
     returnValue.messageText = "";
     info = itemEntity as MixMaterialDetail_mmdl_Info;
     try
     {
         switch (EditMode)
         {
             case Common.DefineConstantValue.EditStateEnum.OE_Insert:
                 bool isExist = false;
                 isExist = _MixMaterialDetailSQL.IsExistRecord(info);
                 if (!isExist)
                 {
                     returnValue.boolValue = _MixMaterialDetailSQL.InsertRecord(info);
                 }
                 else
                 {
                     returnValue.boolValue = false;
                     returnValue.messageText = "數據重複!";
                 }
                 break;
             case Common.DefineConstantValue.EditStateEnum.OE_Update:
                 returnValue.boolValue = _MixMaterialDetailSQL.UpdateRecord(info);
                 break;
             case Common.DefineConstantValue.EditStateEnum.OE_Delete:
                 returnValue.boolValue = _MixMaterialDetailSQL.DeleteRecord(info);
                 break;
         }
     }
     catch (Exception Ex)
     {
         throw Ex;
     }
     return returnValue;
 }
Esempio n. 5
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);
                }
            }
        }
Esempio n. 6
0
        public bool UpdateRecord(MixMaterialDetail_mmdl_Info infoObject)
        {
            bool isSuccess = false;

            using (MainDBDataContext db = new MainDBDataContext())
            {
                MixMaterialDetail_mmdl query = db.MixMaterialDetail_mmdl.SingleOrDefault(t => t.mmdl_Id == infoObject.mmdl_Id);
                if (query != null)
                {
                    query.mmdl_cMaterialCode = infoObject.mmdl_cMaterialCode;
                    query.mmdl_cMaterialGroupNo = infoObject.mmdl_cMaterialGroupNo;
                    query.mmdl_fMaterialProportion = infoObject.mmdl_fMaterialProportion;
                    //query.mlpf_lSync = infoObject.mlpf_lSync;
                    db.SubmitChanges();
                    isSuccess = true;
                }
            }

            return isSuccess;
        }
Esempio n. 7
0
        public List<MixMaterialDetail_mmdl_Info> SearchRecords(IModelObject searchCondition)
        {
            List<MixMaterialDetail_mmdl_Info> list = new List<MixMaterialDetail_mmdl_Info>();
            MixMaterialDetail_mmdl_Info info = new MixMaterialDetail_mmdl_Info();
            info = searchCondition as MixMaterialDetail_mmdl_Info;

            StringBuilder sqlString = new StringBuilder();

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

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

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

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

            IEnumerable<MixMaterialDetail_mmdl_Info> infos = null;

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

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

            return list;
        }
Esempio n. 8
0
        /// <summary>
        /// 物料群組明細主檔
        /// </summary>
        public List<MixMaterialDetail_mmdl_Info> GetMixMaterialDetailMaster()
        {
            try
            {
                List<MixMaterialDetail_mmdl_Info> list = new List<MixMaterialDetail_mmdl_Info>();
                StringBuilder strSql = new StringBuilder();
                strSql.AppendLine("select ");
                strSql.AppendLine("mmdl_Id,mmdl_cMaterialCode,mmdl_cMaterialGroupNo,mmdl_fMaterialProportion ");
                strSql.AppendLine("from MixMaterialDetail_mmdl ");

                using (SqlDataReader sdr = DbHelperSQL.ExecuteReader(strSql.ToString()))
                {
                    while (sdr.Read())
                    {
                        MixMaterialDetail_mmdl_Info model = new MixMaterialDetail_mmdl_Info();
                        if (sdr["mmdl_Id"] != null && sdr["mmdl_Id"].ToString() != "")
                        {
                            model.mmdl_Id = new Guid(sdr["mmdl_Id"].ToString());
                        }
                        if (sdr["mmdl_cMaterialCode"] != null && sdr["mmdl_cMaterialCode"].ToString() != "")
                        {
                            model.mmdl_cMaterialCode = sdr["mmdl_cMaterialCode"].ToString();
                        }
                        if (sdr["mmdl_cMaterialGroupNo"] != null && sdr["mmdl_cMaterialGroupNo"].ToString() != "")
                        {
                            model.mmdl_cMaterialGroupNo = sdr["mmdl_cMaterialGroupNo"].ToString();
                        }
                        if (sdr["mmdl_fMaterialProportion"] != null && sdr["mmdl_fMaterialProportion"].ToString() != "")
                        {
                            model.mmdl_fMaterialProportion = decimal.Parse(sdr["mmdl_fMaterialProportion"].ToString());
                        }
                        list.Add(model);
                    }
                }
                return list;
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Esempio n. 9
0
 private string GetMixMaterialDetailMasterSQL(MixMaterialDetail_mmdl_Info model)
 {
     StringBuilder strSql = new StringBuilder();
     StringBuilder strSql1 = new StringBuilder();
     StringBuilder strSql2 = new StringBuilder();
     if (model.mmdl_Id != null)
     {
         strSql1.Append("mmdl_Id,");
         strSql2.Append("'" + model.mmdl_Id + "',");
     }
     if (model.mmdl_cMaterialCode != null)
     {
         strSql1.Append("mmdl_cMaterialCode,");
         strSql2.Append("'" + model.mmdl_cMaterialCode + "',");
     }
     if (model.mmdl_cMaterialGroupNo != null)
     {
         strSql1.Append("mmdl_cMaterialGroupNo,");
         strSql2.Append("'" + model.mmdl_cMaterialGroupNo + "',");
     }
     if (model.mmdl_fMaterialProportion != null)
     {
         strSql1.Append("mmdl_fMaterialProportion,");
         strSql2.Append("" + model.mmdl_fMaterialProportion + ",");
     }
     strSql.Append("insert into MixMaterialDetail_mmdl(");
     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();
 }