Ejemplo n.º 1
0
 public void BindDataGrid()
 {
     try
     {
         clsItemMaster objLoad = new clsItemMaster();
         objLoad.Mode      = "SELECTALL";
         objLoad.CompanyID = cId;
         dgvItemMaster.AutoGenerateColumns = false;
         var ds = objLoad.GetAllItems();;
         dgvItemMaster.DataSource = ds.Tables[0];
         lblRecordCount.Text      = ds.Tables[0].Rows.Count.ToString();
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message.ToString(), "BindDataGrid", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
Ejemplo n.º 2
0
 public void SearchBindDataGrid()
 {
     try
     {
         dgvItemMaster.DataSource = null;
         clsItemMaster objSearchItems = new clsItemMaster();
         objSearchItems.Mode                = "SELECTALL";
         objSearchItems.CompanyID           = cId;
         objSearchItems.ItemMasterGroupFKey = Convert.ToInt32(cmbSearchItemGroup.SelectedValue);
         objSearchItems.ItemMasterName      = txtSearchItemName.Text;
         objSearchItems.ItemMasterRate      = txtSearchItemRate.Text.Length > 0 ? Convert.ToDecimal(txtSearchItemRate.Text) : 0;
         dgvItemMaster.AutoGenerateColumns  = false;
         var ds = objSearchItems.GetSearchItems();
         dgvItemMaster.DataSource = ds.Tables[0];
         lblRecordCount.Text      = ds.Tables[0].Rows.Count.ToString();
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message.ToString(), "SearchBindDataGrid", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
Ejemplo n.º 3
0
        public void SaveFormData(String mode)
        {
            try
            {
                clsItemMaster objSave = new clsItemMaster();
                objSave.ItemMasterKey           = Convert.ToInt32(txtKey.Text);
                objSave.ItemMasterName          = txtItemName.Text;
                objSave.ItemMasterGroupFKey     = Convert.ToInt32(cmbItemGroup.SelectedValue);
                objSave.ItemMasterGroupFKeyName = cmbItemGroup.Text;
                objSave.ItemWeight        = txtItemWeight.Text.Length > 0 ? Convert.ToDecimal(txtItemWeight.Text) : 0;
                objSave.ItemMasterHsnCode = txtHsnCode.Text;
                //var a   =                       Convert.ToDecimal(txtItemRate.Text)
                objSave.ItemMasterDescription = txtItemDescription.Text;
                objSave.Mode      = mode.ToUpper();
                objSave.CompanyID = cId;
                if (mode.ToUpper().Equals("DELETE"))
                {
                    var confirmation = MessageBox.Show("Are You Sure You Want to Delete " + " " + txtItemName.Text, "Item Master Alert", MessageBoxButtons.YesNo, MessageBoxIcon.Information);
                    if (confirmation.ToString().Equals("Yes"))
                    {
                        objSave.AddUpdateDelete();
                        BindDataGrid();
                        ResetFormControl();
                    }
                }
                else
                {
                    String msg = objSave.Validation();

                    //int isAvaibleinListItem = cmbItemGroup.FindStringExact(cmbItemGroup.Text);
                    //if (isAvaibleinListItem.Equals(-1))
                    //{
                    //    if (msg.Length.Equals(0))
                    //    {
                    //        msg = "Please Select the Item Group From List";
                    //    }
                    //    else
                    //    {
                    //        msg = msg + "\n Please Select the Item Group From List";
                    //    }
                    //}
                    Decimal validRate = 0;
                    Decimal.TryParse(txtItemRate.Text, out validRate);
                    if (validRate.Equals(0) && txtItemRate.Text.Length > 0)
                    {
                        if (msg.Length.Equals(0))
                        {
                            msg = "Please Enter the Valid Rate";
                        }
                        else
                        {
                            msg = msg + "\n Please Enter the Valid Rate";
                        }
                    }
                    if (txtItemRate.Text.Length.Equals(0))
                    {
                        if (msg.Length.Equals(0))
                        {
                            msg = "Please Enter the Rate";
                        }
                        else
                        {
                            msg = msg + "\n Please Enter the Rate";
                        }
                    }
                    //Decimal validStock  =   0;
                    //Decimal.TryParse(txtItemStock.Text, out validStock);
                    //if (validStock.Equals(0) && txtItemStock.Text.Length > 0)
                    //{
                    //    if (msg.Length.Equals(0))
                    //    {
                    //        msg = "Please Enter the Valid Stock";
                    //    }
                    //    else
                    //    {
                    //        msg = msg + "\n Please Enter the Valid Stock";
                    //    }
                    //}

                    if (msg.Length > 0)
                    {
                        MessageBox.Show(msg, "Item Master Alert", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                    else
                    {
                        objSave.ItemMasterRate  = Convert.ToDecimal(txtItemRate.Text);
                        objSave.ItemMasterStock = txtItemStock.Text.Length > 0 ? Convert.ToDecimal(txtItemStock.Text) : 0;
                        //String picName              =   img_file.Substring(img_file.LastIndexOf('\\'));
                        //string path                 =   Application.StartupPath.Substring(0, Application.StartupPath.LastIndexOf("bin"));
                        //Bitmap imgImage             =   new Bitmap(pctBoxItemImage.Image);
                        //imgImage.Save(path + "Resources" + picName);
                        //objSave.ItemMasterImage     =   path + "Resources" + picName;
                        objSave.AddUpdateDelete();
                        MessageBox.Show(txtItemName.Text + " " + mode + " Success Fully", "Item Master Save", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        BindDataGrid();
                        ResetFormControl();
                        if (pageAction.Equals("Yes"))
                        {
                            this.Close();
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message.ToString(), "SaveFormData", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }