コード例 #1
0
        private MaterialBatch objCreateMaterialBatch(DataRow dr)
        {
            MaterialBatch tMaterialBatch = new MaterialBatch();

            tMaterialBatch.SetObjectInfo(dr);
            return(tMaterialBatch);
        }
コード例 #2
0
        public ICollection <MaterialBatch> colGetMaterialBatch(DataTable dt, string argUserName, string clientCode)
        {
            List <MaterialBatch> lst = new List <MaterialBatch>();
            MaterialBatch        objMaterialBatch = null;

            foreach (DataRow dr in dt.Rows)
            {
                objMaterialBatch = new MaterialBatch();
                objMaterialBatch.MaterialCode     = Convert.ToString(dr["MaterialCode"]).Trim();
                objMaterialBatch.PlantCode        = Convert.ToString(dr["PlantCode"]).Trim();
                objMaterialBatch.BatchNumber      = Convert.ToString(dr["BatchNumber"]).Trim();
                objMaterialBatch.ExpiryDate       = Convert.ToString(dr["ExpiryDate"]).Trim();
                objMaterialBatch.AvailabilityDate = Convert.ToString(dr["AvailabilityDate"]).Trim();
                objMaterialBatch.IsDeleted        = Convert.ToInt32(dr["IsDeleted"]);
                objMaterialBatch.ModifiedBy       = Convert.ToString(argUserName).Trim();
                objMaterialBatch.CreatedBy        = Convert.ToString(argUserName).Trim();
                objMaterialBatch.ClientCode       = Convert.ToString(clientCode).Trim();
                lst.Add(objMaterialBatch);
            }
            return(lst);
        }
コード例 #3
0
        public void UpdateMaterialBatch(MaterialBatch argMaterialBatch, DataAccess da, List <ErrorHandler> lstErr)
        {
            SqlParameter[] param = new SqlParameter[11];
            param[0] = new SqlParameter("@MaterialCode", argMaterialBatch.MaterialCode);
            param[1] = new SqlParameter("@PlantCode", argMaterialBatch.PlantCode);
            param[2] = new SqlParameter("@BatchNumber", argMaterialBatch.BatchNumber);
            param[3] = new SqlParameter("@ExpiryDate", argMaterialBatch.ExpiryDate);
            param[4] = new SqlParameter("@AvailabilityDate", argMaterialBatch.AvailabilityDate);
            param[5] = new SqlParameter("@ClientCode", argMaterialBatch.ClientCode);
            param[6] = new SqlParameter("@CreatedBy", argMaterialBatch.CreatedBy);
            param[7] = new SqlParameter("@ModifiedBy", argMaterialBatch.ModifiedBy);

            param[8]           = new SqlParameter("@Type", SqlDbType.Char);
            param[8].Size      = 1;
            param[8].Direction = ParameterDirection.Output;

            param[9]           = new SqlParameter("@Message", SqlDbType.VarChar);
            param[9].Size      = 255;
            param[9].Direction = ParameterDirection.Output;

            param[10]           = new SqlParameter("@returnvalue", SqlDbType.VarChar);
            param[10].Size      = 20;
            param[10].Direction = ParameterDirection.Output;
            int i = da.NExecuteNonQuery("Proc_UpdateMaterialBatch", param);

            string strMessage  = Convert.ToString(param[9].Value);
            string strType     = Convert.ToString(param[8].Value);
            string strRetValue = Convert.ToString(param[10].Value);

            objErrorHandler.Type        = strType;
            objErrorHandler.MsgId       = 0;
            objErrorHandler.Module      = ErrorConstant.strInsertModule;
            objErrorHandler.ModulePart  = ErrorConstant.strMasterModule;
            objErrorHandler.Message     = strMessage.ToString();
            objErrorHandler.RowNo       = 0;
            objErrorHandler.FieldName   = "";
            objErrorHandler.LogCode     = "";
            objErrorHandler.ReturnValue = strRetValue;
            lstErr.Add(objErrorHandler);
        }
コード例 #4
0
        public ICollection <MaterialBatch> colGetMaterialBatch(string argClientCode)
        {
            List <MaterialBatch> lst     = new List <MaterialBatch>();
            DataSet       DataSetToFill  = new DataSet();
            MaterialBatch tMaterialBatch = new MaterialBatch();

            DataSetToFill = this.GetMaterialBatch(argClientCode);

            if (DataSetToFill != null)
            {
                foreach (DataRow dr in DataSetToFill.Tables[0].Rows)
                {
                    lst.Add(objCreateMaterialBatch(dr));
                }
            }
            goto Finish;

Finish:
            DataSetToFill = null;

            return(lst);
        }
コード例 #5
0
        public MaterialBatch objGetMaterialBatch(string argMaterialCode, string argPlantCode, string argClientCode)
        {
            MaterialBatch argMaterialBatch = new MaterialBatch();
            DataSet       DataSetToFill    = new DataSet();

            if (argMaterialCode.Trim() == "")
            {
                goto ErrorHandlers;
            }

            if (argPlantCode.Trim() == "")
            {
                goto ErrorHandlers;
            }

            if (argClientCode.Trim() == "")
            {
                goto ErrorHandlers;
            }

            DataSetToFill = this.GetMaterialBatch(argMaterialCode, argPlantCode, argClientCode);

            if (DataSetToFill.Tables[0].Rows.Count <= 0)
            {
                goto Finish;
            }
            argMaterialBatch = this.objCreateMaterialBatch((DataRow)DataSetToFill.Tables[0].Rows[0]);

            goto Finish;

ErrorHandlers:

Finish:
            DataSetToFill = null;

            return(argMaterialBatch);
        }
コード例 #6
0
        public ICollection <ErrorHandler> SaveMaterialBatch(MaterialBatch argMaterialBatch)
        {
            List <ErrorHandler> lstErr = new List <ErrorHandler>();
            DataAccess          da     = new DataAccess();

            try
            {
                if (blnIsMaterialBatchExists(argMaterialBatch.MaterialCode, argMaterialBatch.PlantCode, argMaterialBatch.ClientCode) == false)
                {
                    da.Open_Connection();
                    da.BEGIN_TRANSACTION();
                    InsertMaterialBatch(argMaterialBatch, da, lstErr);
                    foreach (ErrorHandler objerr in lstErr)
                    {
                        if (objerr.Type == "E")
                        {
                            da.ROLLBACK_TRANSACTION();
                            return(lstErr);
                        }
                    }
                    da.COMMIT_TRANSACTION();
                }
                else
                {
                    da.Open_Connection();
                    da.BEGIN_TRANSACTION();
                    UpdateMaterialBatch(argMaterialBatch, da, lstErr);
                    foreach (ErrorHandler objerr in lstErr)
                    {
                        if (objerr.Type == "E")
                        {
                            da.ROLLBACK_TRANSACTION();
                            return(lstErr);
                        }
                    }
                    da.COMMIT_TRANSACTION();
                }
            }
            catch (Exception ex)
            {
                if (da != null)
                {
                    da.ROLLBACK_TRANSACTION();
                }
                objErrorHandler.Type       = ErrorConstant.strAboartType;
                objErrorHandler.MsgId      = 0;
                objErrorHandler.Module     = ErrorConstant.strInsertModule;
                objErrorHandler.ModulePart = ErrorConstant.strMasterModule;
                objErrorHandler.Message    = ex.Message.ToString();
                objErrorHandler.RowNo      = 0;
                objErrorHandler.FieldName  = "";
                objErrorHandler.LogCode    = "";
                lstErr.Add(objErrorHandler);
            }
            finally
            {
                if (da != null)
                {
                    da.Close_Connection();
                    da = null;
                }
            }
            return(lstErr);
        }