示例#1
0
        public bool SaveMCG(MaterialCentreGroupMasterModel objMCG)
        {
            string Query   = string.Empty;
            bool   isSaved = true;

            try
            {
                DBParameterCollection paramCollection = new DBParameterCollection();

                paramCollection.Add(new DBParameter("@Group", objMCG.Group));
                paramCollection.Add(new DBParameter("@Alias", objMCG.Alias));
                paramCollection.Add(new DBParameter("@PrimaryGroup", objMCG.PrimaryGroup, System.Data.DbType.Boolean));
                paramCollection.Add(new DBParameter("@UnderGroup", objMCG.UnderGroup));
                paramCollection.Add(new DBParameter("@CreatedBy", objMCG.CreatedBy));

                Query = "INSERT INTO MaterialCentreGroupMaster(`Group`,`Alias`,`PrimaryGroup`,`UnderGroup`,`CreatedBy`) " +
                        "VALUES(@Group,@Alias,@PrimaryGroup,@UnderGroup,@CreatedBy)";

                if (_dbHelper.ExecuteNonQuery(Query, paramCollection) > 0)
                {
                    isSaved = true;
                }
            }
            catch (Exception ex)
            {
                isSaved = false;
                throw ex;
            }

            return(isSaved);
        }
示例#2
0
        //update
        public bool UpdateMCG(MaterialCentreGroupMasterModel objMCG)
        {
            string Query     = string.Empty;
            bool   isUpdated = true;

            try
            {
                DBParameterCollection paramCollection = new DBParameterCollection();

                paramCollection.Add(new DBParameter("@Group", objMCG.Group));
                paramCollection.Add(new DBParameter("@Alias", objMCG.Alias));
                paramCollection.Add(new DBParameter("@PrimaryGroup", objMCG.PrimaryGroup, System.Data.DbType.Boolean));
                paramCollection.Add(new DBParameter("@UnderGroup", objMCG.UnderGroup));
                paramCollection.Add(new DBParameter("@ModifiedBy", objMCG.ModifiedBy));
                paramCollection.Add(new DBParameter("@MCG_ID", objMCG.MCG_ID));
                paramCollection.Add(new DBParameter("@ModifiedBy", objMCG.ModifiedBy));

                Query = "UPDATE MaterialCentreGroupMaster SET [Group]=@Group,[Alias]=@Alias,[PrimaryGroup]=@PrimaryGroup,[UnderGroup]=@UnderGroup, " +
                        "[ModifiedBy]=@ModifiedBy WHERE MCG_Id=@MCG_Id";

                if (_dbHelper.ExecuteNonQuery(Query, paramCollection) > 0)
                {
                    isUpdated = true;
                }
            }
            catch (Exception ex)
            {
                isUpdated = false;
                throw ex;
            }

            return(isUpdated);
        }
示例#3
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            if (tbxGroupName.Text.Equals(string.Empty))
            {
                MessageBox.Show("Group Name can not be blank!");
                return;
            }
            MaterialCentreGroupMasterModel objGroup = new MaterialCentreGroupMasterModel();

            objGroup.Group        = tbxGroupName.Text.TrimEnd();
            objGroup.Alias        = tbxAliasname.Text == null?string.Empty:tbxAliasname.Text;
            objGroup.PrimaryGroup = cbxPrimarygroup.SelectedItem.ToString() == "Y" ? true : false;
            if (cbxPrimarygroup.SelectedItem.ToString() == "N")
            {
                objGroup.UnderGroup = cbxUndergroup.SelectedItem.ToString();
            }

            objGroup.CreatedBy = "Admin";

            bool isSuccess = MatObj.SaveMCG(objGroup);

            if (isSuccess)
            {
                MessageBox.Show("Saved Successfully!");
                ClearControls();
            }
        }
示例#4
0
        private void btnUpdate_Click(object sender, EventArgs e)
        {
            MaterialCentreGroupMasterModel objGroup = new MaterialCentreGroupMasterModel();

            objGroup.Group        = tbxGroupName.Text.TrimEnd();
            objGroup.Alias        = tbxAliasname.Text == null ? string.Empty : tbxAliasname.Text;
            objGroup.PrimaryGroup = cbxPrimarygroup.SelectedItem.ToString() == "Y" ? true : false;
            if (cbxPrimarygroup.SelectedItem.ToString() == "N")
            {
                objGroup.UnderGroup = cbxUndergroup.SelectedItem.ToString();
            }

            objGroup.CreatedBy = "Admin";
            objGroup.MCG_ID    = MCGId;

            bool isSuccess = MatObj.UpdateMCG(objGroup);

            if (isSuccess)
            {
                MessageBox.Show("Update Successfully!");
                MCGId = 0;
                ClearControls();
                Administration.List.MaterialcentergrpList frmList = new Administration.List.MaterialcentergrpList();
                frmList.StartPosition = FormStartPosition.CenterScreen;

                frmList.ShowDialog();
                FillMaterialGroupInfo();
            }
        }
        //update
        public bool UpdateMCG(MaterialCentreGroupMasterModel objMCG)
        {
            string Query     = string.Empty;
            bool   isUpdated = true;

            try
            {
                DBParameterCollection paramCollection = new DBParameterCollection();

                paramCollection.Add(new DBParameter("@Group", objMCG.Group));
                paramCollection.Add(new DBParameter("@Alias", objMCG.Alias));
                paramCollection.Add(new DBParameter("@PrimaryGroup", objMCG.PrimaryGroup, System.Data.DbType.Boolean));
                paramCollection.Add(new DBParameter("@UnderGroup", objMCG.UnderGroup));
                paramCollection.Add(new DBParameter("@MCG_ID", objMCG.MCG_ID));


                Query = "UPDATE `materialcentregroupmaster` SET `Group`=@Group,Alias=@Alias,`PrimaryGroup`=@PrimaryGroup,UnderGroup=@UnderGroup " +
                        "WHERE MCG_ID=@MCG_ID";


                if (_dbHelper.ExecuteNonQuery(Query, paramCollection) > 0)
                {
                    isUpdated = true;
                }
            }
            catch (Exception ex)
            {
                isUpdated = false;
                throw ex;
            }

            return(isUpdated);
        }
        //Get List To Update By Id
        public MaterialCentreGroupMasterModel GetAllMaterialGroupsById(int id)
        {
            MaterialCentreGroupMasterModel objMCG = new MaterialCentreGroupMasterModel();

            string Query = "SELECT * FROM `materialcentregroupmaster` WHERE MCG_ID=" + id + "";

            System.Data.IDataReader dr = _dbHelper.ExecuteDataReader(Query, _dbHelper.GetConnObject());

            while (dr.Read())
            {
                objMCG.MCG_ID       = Convert.ToInt32(dr["MCG_ID"]);
                objMCG.Group        = dr["Group"].ToString();
                objMCG.Alias        = dr["Alias"].ToString();
                objMCG.PrimaryGroup = Convert.ToBoolean(dr["PrimaryGroup"]);
                objMCG.UnderGroup   = dr["UnderGroup"].ToString();
            }

            return(objMCG);
        }
示例#7
0
        private void FillMaterialGroupInfo()
        {
            if (MCGId == 0)
            {
                tbxGroupName.Focus();
                ClearControls();
                lblUpdate.Visibility = DevExpress.XtraLayout.Utils.LayoutVisibility.OnlyInCustomization;
                lblSave.Visibility   = DevExpress.XtraLayout.Utils.LayoutVisibility.Always;
                lblDelete.Visibility = DevExpress.XtraLayout.Utils.LayoutVisibility.OnlyInCustomization;
                return;
            }
            MaterialCentreGroupMasterModel objMaster = MatObj.GetAllMaterialGroupsById(MCGId);

            tbxGroupName.Text            = objMaster.Group;
            tbxAliasname.Text            = objMaster.Alias;
            cbxPrimarygroup.SelectedItem = Convert.ToString((objMaster.PrimaryGroup) ? "Y" : "N");
            cbxUndergroup.SelectedItem   = objMaster.UnderGroup;
            lblUpdate.Visibility         = DevExpress.XtraLayout.Utils.LayoutVisibility.Always;
            lblSave.Visibility           = DevExpress.XtraLayout.Utils.LayoutVisibility.OnlyInCustomization;
            lblDelete.Visibility         = DevExpress.XtraLayout.Utils.LayoutVisibility.Always;
            tbxGroupName.Focus();
        }
        private void btnSave_Click(object sender, EventArgs e)
        {
            MaterialCentreGroupMasterModel objGroup = new MaterialCentreGroupMasterModel();

            objGroup.Group        = tbxGroupName.Text.TrimEnd();
            objGroup.Alias        = tbxAliasname.Text.Trim();
            objGroup.PrimaryGroup = cbxPrimarygroup.SelectedItem.ToString() == "Y" ? true : false;
            objGroup.UnderGroup   = cbxUndergroup.SelectedItem.ToString();
            objGroup.CreatedBy    = "Admin";

            bool isSuccess = MatObj.SaveMCG(objGroup);

            if (isSuccess)
            {
                MessageBox.Show("Saved Successfully!");
            }
            //List<MaterialCentreGroupMasterModel> lstGroups = MatObj.GetAllMaterialGroups();
            //dgvList.DataSource = lstGroups;
            //Dialogs.PopUPDialog d = new Dialogs.PopUPDialog("Saved Successfully!");
            //d.ShowDialog();
            //btnSave.Visible = true;
        }
        //List

        public List <MaterialCentreGroupMasterModel> GetAllMaterialGroups()
        {
            List <MaterialCentreGroupMasterModel> lstMCG = new List <MaterialCentreGroupMasterModel>();
            MaterialCentreGroupMasterModel        objMCG;

            string Query = "SELECT * FROM `materialcentregroupmaster`";

            System.Data.IDataReader dr = _dbHelper.ExecuteDataReader(Query, _dbHelper.GetConnObject());

            while (dr.Read())
            {
                objMCG = new MaterialCentreGroupMasterModel();

                objMCG.MCG_ID       = Convert.ToInt32(dr["MCG_ID"]);
                objMCG.Group        = dr["Group"].ToString();
                objMCG.PrimaryGroup = Convert.ToBoolean(dr["PrimaryGroup"]);
                objMCG.UnderGroup   = dr["UnderGroup"].ToString();

                lstMCG.Add(objMCG);
            }

            return(lstMCG);
        }