コード例 #1
0
 private void ValidateExcelItemDetails(AddItemBo objboAdditem)
 {
     try
     {
         //sb = new StringBuilder();
         //sbValidateExcelItem = new StringBuilder();
         objcontroler.CheckDataHavingInDataTableOrNot(objboAdditem, Login.UserId);
         txtItemKey.Text     = objboAdditem.ItemCode;
         txtDescription.Text = objboAdditem.ItemDesc;
         txtQuantity.Text    = objboAdditem.Quantity.ToString();
         //  cmbCategory.Items.Add(objboAdditem.ItemCateGory);
         cmbCategory.Text = objboAdditem.ItemCateGory;
         //  cmbItemGroup.Items.Add(objboAdditem.ItemGroup);
         cmbItemGroup.Text = objboAdditem.ItemGroup;
         // cmbLocation.Items.Add(objboAdditem.Location);
         //   cmbLocation.Text = objboAdditem.Location;
         // cmbSupplier.Items.Add(objboAdditem.Supplier);
         cmbSupplier.Text = objboAdditem.Supplier;
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message, this.Text, MessageBoxButtons.OK, MessageBoxIcon.Error);
         return;
     }
 }
コード例 #2
0
        private void gvInsertExcelINewtems_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
        {
            try
            {
                AddItemBo       objboAdditem = new AddItemBo();
                DataGridViewRow row          = this.gvInsertExcelINewtems.SelectedRows[0];
                // objboAdditem.Location = (string)row.Cells["Location"].Value;
                objboAdditem.ItemCode     = (string)row.Cells["ItemCode"].Value;
                objboAdditem.ItemDesc     = (string)row.Cells["ItemDescription"].Value;
                objboAdditem.BarCode      = (string)row.Cells["BarCode"].Value;
                objboAdditem.ItemGroup    = (string)row.Cells["SubGroup"].Value;
                objboAdditem.ItemCateGory = (string)row.Cells["Group"].Value;
                objboAdditem.Supplier     = (string)row.Cells["Supplier"].Value;
                objboAdditem.Quantity     = Convert.ToInt32(row.Cells["Quantity"].Value);
                AddaNewItem obj = new AddaNewItem(objboAdditem);
                obj.ShowDialog();


                string itemcode = (string)row.Cells["ItemCode"].Value;
                DeleteAddedItem(itemcode);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, this.Text, MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
        }
コード例 #3
0
        public void InsertItemDetailsFn(AddItemBo objbo)
        {
            try
            {
                if (IsCabinet)
                {
                    objPort = new SerialPort();
                    string[] ArrayComPortsNames = null;
                    string   portname           = string.Empty;
                    ArrayComPortsNames = SerialPort.GetPortNames();
                    if (ArrayComPortsNames.Length > 0)
                    {
                        objPort.PortName = ArrayComPortsNames[0];

                        if (objPort != null && objPort.IsOpen)
                        {
                            objPort.Close();
                        }
                        objPort.Parity       = Parity.None;
                        objPort.StopBits     = StopBits.One;
                        objPort.DataBits     = 8;
                        objPort.Handshake    = Handshake.None;
                        objPort.RtsEnable    = true;
                        objPort.WriteTimeout = 2000;
                        objPort.Open();
                        objPort.WriteLine("BIC");
                        Thread.Sleep(2000);
                        objPort.WriteLine(objbo.Location);
                    }
                    else
                    {
                        MessageBox.Show("System couldn't find a cabinet, please connect it.", this.Text);
                        return;
                    }
                }
                int i = objcontroler.InsertItemDetails(objbo, Login.UserId);
                if (i != 0)
                {
                    MessageBox.Show("Data Saved Successfully.", this.Text);
                    Clear();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, this.Text, MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            finally
            {
                if (IsCabinet)
                {
                    objPort.Close();
                }
            }
        }
コード例 #4
0
 public int UpdateItemDetails(AddItemBo objbo, int UserId, int ItemCode)
 {
     try
     {
         return(objDAL.UpdateItemDetails(objbo, UserId, ItemCode));
     }
     catch (Exception)
     {
         throw;
     }
 }
コード例 #5
0
 public int InsertItemDetails(AddItemBo objbo, int UserId)
 {
     try
     {
         return(objDAL.InsertItemDetails(objbo, UserId));
     }
     catch (Exception)
     {
         throw;
     }
 }
コード例 #6
0
        public int InsertOrUpdateItemFromExcel(AddItemBo objbo)
        {
            try
            {
                int i = objDAL.InsertOrUpdateItemFromExcel(objbo);
                //   TooLManagementEntities objEntites = new TooLManagementEntities();

                return(i);
            }
            catch (Exception)
            {
                throw;
            }
        }
コード例 #7
0
 public AddaNewItem(AddItemBo objboAdditem)
 {
     try
     {
         InitializeComponent();
         BindCategory();
         BindSuppliers();
         BindDrawer();
         ValidateExcelItemDetails(objboAdditem);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
コード例 #8
0
 public void UpdateItemDetails(AddItemBo objbo, int ItemCode)
 {
     try
     {
         // ToolBAL objcontroler = new ToolBAL();
         int i = objcontroler.UpdateItemDetails(objbo, Login.UserId, ItemCode);
         if (i != 0)
         {
             MessageBox.Show("Data Updated Successfully.", this.Text);
             CallBackToolDetailsBind();
             this.Hide();
             // GetItemsinfo();
             // GvIteminfo();
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message, this.Text, MessageBoxButtons.OK, MessageBoxIcon.Error);
         return;
     }
 }
コード例 #9
0
        public bool CheckDataHavingInDataTableOrNot(AddItemBo objboAdditem, int UserId)
        {
            bool checkresult = false;

            try
            {
                if (objboAdditem.ItemCateGory != null)
                {
                    coluMnName = "ItemCategory";
                    string value = objboAdditem.ItemCateGory;
                    checkresult = objDAL.CheckDataHavingInDataTableOrNot(coluMnName, value);
                    if (!checkresult)
                    {
                        objDAL.InsertNewCategory(value, UserId);
                    }
                }
                if (objboAdditem.ItemGroup != null)
                {
                    coluMnName = "ItemGroup";
                    string checkItemcategory = objboAdditem.ItemCateGory;
                    string checkvalue        = objboAdditem.ItemGroup;
                    checkresult = objDAL.CheckItemSubGroup(coluMnName, checkItemcategory, checkvalue);
                    if (!checkresult)
                    {
                        int itemCateGoryId = objDAL.GetCategoryId(objboAdditem.ItemCateGory);
                        InsertGroup(itemCateGoryId, checkvalue, UserId);
                    }
                }

                if (objboAdditem.Supplier != null)
                {
                    coluMnName  = "Company";
                    value       = objboAdditem.Supplier;
                    checkresult = objDAL.CheckDataHavingInDataTableOrNot(coluMnName, value);
                    if (!checkresult)
                    {
                        SupplierDetails objbo        = new SupplierDetails();
                        string          supplierName = string.Empty;
                        supplierName = objboAdditem.Supplier;
                        SupplierDetails objSupplierDetails = new SupplierDetails();
                        objSupplierDetails.SupplierName      =
                            objSupplierDetails.MiddleName    = "";
                        objSupplierDetails.LastName          = "";
                        objSupplierDetails.Company           = supplierName;
                        objSupplierDetails.Displayname       = "";
                        objSupplierDetails.Mobile            = "";
                        objSupplierDetails.Email             = "";
                        objSupplierDetails.Address           = "";
                        objSupplierDetails.Phone             = "";
                        objSupplierDetails.Fax               = "";
                        objSupplierDetails.AccountNo         = "";
                        objSupplierDetails.PanNumber         = "";
                        objSupplierDetails.TaxRegistrationNo = "";
                        objSupplierDetails.SupplierCode      = "";
                        objSupplierDetails.City              = "";
                        objSupplierDetails.State             = "";
                        objSupplierDetails.Country           = "";
                        objSupplierDetails.PostalCode        = "";
                        objSupplierDetails.Notes             = "";
                        objSupplierDetails.UserId            = 0;
                        int i = AddSupplierDetails(objSupplierDetails);

                        if (i != 0)
                        {
                            checkresult = true;
                        }
                    }
                }

                return(checkresult);

                // return dt;
            }
            catch (Exception)
            {
                throw;
            }
        }
コード例 #10
0
        public int InsertOrUpdateExcelItem(string typeOfMethod, DataTable dtExcelItemsForInsertOrUpdate)
        {
            try
            {
                int       count = 0;
                int       i     = 0;
                AddItemBo objbo = new AddItemBo();
                if (dtExcelItemsForInsertOrUpdate != null && dtExcelItemsForInsertOrUpdate.Rows.Count > 0)
                {
                    bool result = false;
                    foreach (DataRow item in dtExcelItemsForInsertOrUpdate.Rows)
                    {
                        objbo.TypeOfmethod = typeOfMethod;
                        //  objbo.Location = item["Location"].ToString();
                        objbo.ItemCode     = item["Item code"].ToString();
                        objbo.ItemDesc     = item["Item description"].ToString();
                        objbo.BarCode      = item["Bar code"].ToString();
                        objbo.ItemCateGory = item["Category"].ToString();
                        objbo.ItemGroup    = item["Group"].ToString();
                        objbo.ItemType     = item["Item type"].ToString();
                        objbo.Supplier     = item["Supplier"].ToString();
                        objbo.Quantity     = Convert.ToInt32(item["Quantity"]);
                        objbo.Accesslevel  = Convert.ToInt32(item["Access level"]);
                        objbo.MOQ          = Convert.ToInt32(item["MOQ"].ToString());
                        objbo.UserId       = Login.UserId;
                        objbo.IsAdmin      = Login.IsAdmin;
                        if (objbo.TypeOfmethod == "InsertItemFromExcel")
                        {
                            result = objcontroler.CheckDataHavingInDataTableOrNot(objbo, Login.UserId);
                            if (result == true)
                            {
                                i = objcontroler.InsertOrUpdateItemFromExcel(objbo);
                            }
                        }
                        else
                        {
                            i = objcontroler.InsertOrUpdateItemFromExcel(objbo);
                        }


                        if (i != 0)
                        {
                            count = count + 1;
                        }
                        else
                        {
                            MessageBox.Show(" Items  are not Inserted From excel please try again");
                        }
                    }
                    if (objbo.TypeOfmethod == "InsertItemFromExcel")
                    {
                        if (count == 1)
                        {
                            MessageBox.Show(count + " Item  has  Inserted From excel");
                        }
                        else
                        {
                            MessageBox.Show(count + " Items  are Inserted From excel");
                        }
                        gvInsertExcelINewtems.DataSource = null;
                        dtExcelItemsForInsert            = null;
                    }
                    if (objbo.TypeOfmethod == "UpdateItemFromExcel")
                    {
                        if (count == 1)
                        {
                            MessageBox.Show(count + " Item  has Updated From excel");
                        }
                        else
                        {
                            MessageBox.Show(count + " Items  are Updated From excel");
                        }
                        dtExcelItemsToUpdate        = null;
                        gvUpdateExceltem.DataSource = null;
                    }
                }
                else
                {
                    MessageBox.Show("There is no Data To  Insert/UpDatae ! Please Browse  File Data");
                }
                return(i);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
コード例 #11
0
 public void UpdateExcelFileToGrids(DataTable dtExcelItemInfo)
 {
     try
     {
         int Qnt         = 0;
         int rowCount    = 0;
         int Accesslevel = 0;
         int Moq1        = 0;
         gvUpdateExceltem.DataSource      = null;
         gvInsertExcelINewtems.DataSource = null;
         AddItemBo objbo = new AddItemBo();
         //Columns For InsertExcelIems
         CreateExcelGridColumns();
         checkMatchingColumnsCount = CompareSelectedExcelColumnsMatchng(dtExcelItemInfo);
         if (checkMatchingColumnsCount == 0)
         {
             if (dtExcelItemInfo != null && dtExcelItemInfo.Rows.Count > 0)
             {
                 foreach (DataRow item in dtExcelItemInfo.Rows)
                 {
                     rowCount = rowCount + 1;
                     Validations(item);
                     // objbo.Location = item["Location"].ToString();
                     if (sb != null && sb.ToString() != string.Empty)
                     {
                         sb.Append(" In Excel File at Row No  " + rowCount);
                         MessageBox.Show(sb.ToString());
                     }
                     else
                     {
                         objbo.ItemCode     = item["Item code"].ToString();
                         objbo.ItemDesc     = item["Item description"].ToString();
                         objbo.BarCode      = item["Bar code"].ToString();
                         objbo.ItemCateGory = item["Category"].ToString();
                         objbo.ItemGroup    = item["Group"].ToString();
                         objbo.ItemType     = item["Item type"].ToString();
                         objbo.Supplier     = item["Supplier"].ToString();
                         if (int.TryParse(item["Quantity"].ToString(), out Qnt))
                         {
                             objbo.Quantity = Qnt;
                         }
                         if (int.TryParse(item["Access Level"].ToString(), out Accesslevel))
                         {
                             objbo.Accesslevel = Accesslevel;
                         }
                         if (int.TryParse(item["MOQ"].ToString(), out Moq1))
                         {
                             objbo.MOQ = Moq1;
                         }
                         objbo.UserId  = Login.UserId;
                         objbo.IsAdmin = Login.IsAdmin;
                         columnName    = "ItemCode";
                         value         = objbo.ItemCode;
                         bool checkItemCode = objcontroler.ItemCodeContains(columnName, value);
                         if (checkItemCode == true)
                         {
                             DataRow drExcelItemsToUpdate = dtExcelItemsToUpdate.NewRow();
                             // drExcelItemsToUpdate["Location"] = objbo.Location;
                             drExcelItemsToUpdate["Item code"]        = objbo.ItemCode;
                             drExcelItemsToUpdate["Item description"] = objbo.ItemDesc;
                             drExcelItemsToUpdate["Bar code"]         = objbo.BarCode;
                             drExcelItemsToUpdate["Category"]         = objbo.ItemCateGory;
                             drExcelItemsToUpdate["Group"]            = objbo.ItemGroup;
                             drExcelItemsToUpdate["Item type"]        = objbo.ItemType;
                             drExcelItemsToUpdate["Supplier"]         = objbo.Supplier;
                             drExcelItemsToUpdate["Quantity"]         = objbo.Quantity;
                             drExcelItemsToUpdate["Access Level"]     = objbo.Accesslevel;
                             drExcelItemsToUpdate["MOQ"] = objbo.MOQ;
                             dtExcelItemsToUpdate.Rows.Add(drExcelItemsToUpdate);
                             sb = null;
                         }
                         else
                         {
                             DataRow drExcelItemsForInsert = dtExcelItemsForInsert.NewRow();
                             //drExcelItemsForInsert["Location"] = objbo.Location;
                             drExcelItemsForInsert["Item code"]        = objbo.ItemCode;
                             drExcelItemsForInsert["Item description"] = objbo.ItemDesc;
                             drExcelItemsForInsert["Bar code"]         = objbo.BarCode;
                             drExcelItemsForInsert["Category"]         = objbo.ItemCateGory;
                             drExcelItemsForInsert["Group"]            = objbo.ItemGroup;
                             drExcelItemsForInsert["Item type"]        = objbo.ItemType;
                             drExcelItemsForInsert["Supplier"]         = objbo.Supplier;
                             drExcelItemsForInsert["Quantity"]         = objbo.Quantity;
                             drExcelItemsForInsert["Access Level"]     = objbo.Accesslevel;
                             drExcelItemsForInsert["MOQ"] = objbo.MOQ;
                             dtExcelItemsForInsert.Rows.Add(drExcelItemsForInsert);
                             sb = null;
                         }
                     }
                 }
                 if (sb == null)
                 {
                     gvUpdateExceltem.DataSource      = dtExcelItemsToUpdate;
                     gvInsertExcelINewtems.DataSource = dtExcelItemsForInsert;
                 }
             }
             else
             {
                 MessageBox.Show("There Is No Data In Excel Please Insert Data", this.Text);
             }
         }
         else
         {
             if (checkMatchingColumnsCount == 1)
             {
                 MessageBox.Show("There is " + checkMatchingColumnsCount + " Miss matched Columns  please Download Defualt Templeate again !", this.Text);
             }
             else
             {
                 MessageBox.Show("There are " + checkMatchingColumnsCount + " Miss matched Columns  please Download Defualt Templeate again !", this.Text);
             }
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }