private void frmAddAssemblyChildItems_Load(object sender, EventArgs e) { splitContainerMain.SplitterDistance = (int)(this.Height * .5); PopulateItemCategoryDropdown(); cboItemCategory.SelectedIndex = 0; TBL_MP_Master_Item dbItem = (new ServiceInventoryItems()).GetItemDBRecord(this.AssemblyItemID); if (dbItem != null) { this.Text = string.Format("ASSEMBLY: {0}", dbItem.Item_Name); } PopulateAssemblyChildItems(); }
private void Scatterdata() { TBL_MP_Master_Item model = (new ServiceInventoryItems()).GetItemDBRecord(this.ItemID); if (model != null) { txtItemID.Text = model.Pk_ItemID.ToString(); txtItemCode.Text = model.ItemCode.ToString(); txtHSNCode.Text = model.HSNCode; txtItemName.Text = model.Item_Name; txtSpecificName.Text = model.Long_Description; txtPartNumber.Text = model.PartNumber; chkIsAssembly.Checked = (bool)model.IsAssembly; if (model.UniqueString != null) { _uniqueString = model.UniqueString; } if (model.Fk_UserList_ItemType_ID != null) { this.SelectedItemTypeID = (int)model.Fk_UserList_ItemType_ID; cboItemType.SelectedItem = ((List <SelectListItem>)cboItemType.DataSource).Where(x => x.ID == model.Fk_UserList_ItemType_ID).FirstOrDefault(); PopulateItemCategoryDropdown(); } if (model.Fk_InvCategory_ID != null) { this.SelectedCategoryID = (int)model.Fk_InvCategory_ID; cboItemCategory.SelectedItem = ((List <SelectListItem>)cboItemCategory.DataSource).Where(x => x.ID == model.Fk_InvCategory_ID).FirstOrDefault(); PopulateSpecificationsGrid(); } if (model.Fk_UserList_BaseUOM_ID != null) { SelectListItem selUnit = ((List <SelectListItem>)cboUOM.DataSource).Where(x => x.ID == model.Fk_UserList_BaseUOM_ID).FirstOrDefault(); if (selUnit != null) { cboUOM.SelectedItem = selUnit; } } if (model.Fk_UserList_PurchaseUOM_ID != null) { SelectListItem selUnit = ((List <SelectListItem>)cboPurchaseUOM.DataSource).Where(x => x.ID == model.Fk_UserList_PurchaseUOM_ID).FirstOrDefault(); if (selUnit != null) { cboPurchaseUOM.SelectedItem = selUnit; } } } }
private void btnSave_Click(object sender, EventArgs e) { ServiceInventoryItems _InventoryItemService = new ServiceInventoryItems(); errorProvider1.Clear(); if (this.ValidateChildren()) { try { TBL_MP_Master_Item item = this.GatherData(); PrepareDuplicacyCheckProgressBar(); if (progressBar1.Value == progressBar1.Maximum) { string strMEssage = "The same set of Specification is already assign to any other Item.\nDo you still wish to save this Item"; DialogResult choice = MessageBox.Show(strMEssage, "CAUTION", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (choice == DialogResult.No) { return; } } if (item.Pk_ItemID == 0) { ItemID = _InventoryItemService.AddNewInventoryItemMasterInfo(item); } else { bool result = _InventoryItemService.UpdateInventoryItemMasterInfo(item); } _InventoryItemService.UpdateInventoryItemSpecifications(lstItemSpecifications, ItemID); this.DialogResult = DialogResult.OK; } catch (Exception ex) { string errMessage = ex.Message; if (ex.InnerException != null) { errMessage += string.Format("\n{0}", ex.InnerException.Message); } MessageBox.Show(ex.Message, "frmAddEditInventoryItem::btnSave_Click", MessageBoxButtons.OK, MessageBoxIcon.Error); } } }
private TBL_MP_Master_Item GatherData() { TBL_MP_Master_Item model = null; try { if (this.ItemID == 0) { model = new TBL_MP_Master_Item(); model.Pk_ItemID = 0; } else { model = (new ServiceInventoryItems()).GetItemDBRecord(this.ItemID); } model.ItemCode = txtItemCode.Text; model.HSNCode = txtHSNCode.Text; model.PartNumber = txtPartNumber.Text.Trim(); model.Item_Name = txtItemName.Text.Trim().ToUpper(); model.Long_Description = txtSpecificName.Text.Trim(); model.Fk_UserList_ItemType_ID = ((SelectListItem)cboItemType.SelectedItem).ID; model.Fk_InvCategory_ID = ((SelectListItem)cboItemCategory.SelectedItem).ID; model.Fk_UserList_BaseUOM_ID = ((SelectListItem)cboUOM.SelectedItem).ID; model.Fk_UserList_PurchaseUOM_ID = ((SelectListItem)cboPurchaseUOM.SelectedItem).ID; model.IsAssembly = chkIsAssembly.Checked; } catch (Exception ex) { string errMessage = ex.Message; if (ex.InnerException != null) { errMessage += string.Format("\n{0}", ex.InnerException.Message); } MessageBox.Show(ex.Message, "frmAddEditInventoryItem::GatherData", MessageBoxButtons.OK, MessageBoxIcon.Error); } return(model); }
private void PopulateDescription() { try { switch (this.ENTITY) { case APP_ENTITIES.INVENTORY_ITEM: TBL_MP_Master_Item dbItem = (new ServiceInventoryItems()).GetItemDBRecord(this.ENTITY_ID); if (dbItem != null) { txtDescription.Text = string.Format("{0}\n{1}\nCODE: {2}", dbItem.Item_Name, dbItem.Long_Description, dbItem.ItemCode); } break; case APP_ENTITIES.PARTIES: Tbl_MP_Master_Party dbParty = (new ServiceParties()).GetPartyByPartyID(this.ENTITY_ID); if (dbParty != null) { txtDescription.Text = string.Format("{0} ({1})\n{2}", dbParty.PartyName, dbParty.PartyType, dbParty.PartyCode); } break; case APP_ENTITIES.INVENTORY_ITEM_ATTACHMENT: TBL_MP_Master_Item_Attachments dbItemAttachment = (new ServiceInventoryItems()).GetInventoryItemAttachmentDBRecord(this.ENTITY_ID); if (dbItemAttachment != null) { txtDescription.Text = string.Format("ATTACHMENT: {0}\nITEM:{1}\n{2}", dbItemAttachment.Title.ToUpper(), dbItemAttachment.TBL_MP_Master_Item.Item_Name, dbItemAttachment.TBL_MP_Master_Item.Long_Description); } break; case APP_ENTITIES.APPLICATION_MODULES: Tbl_MP_Master_Module dbModule = (new ServiceModules()).GetModuleDBRecordByID(this.ENTITY_ID); if (dbModule != null) { txtDescription.Text = string.Format("NAME: {0}\nDISPLAY: {1}", dbModule.ModuleName, dbModule.DisplayName); } break; case APP_ENTITIES.MODULES_FORMS: Tbl_MP_Master_Module_Forms dbForm = (new ServiceModules()).GetModuleFormDBRecordByID(this.ENTITY_ID); if (dbForm != null) { txtDescription.Text = string.Format("NAME: {0}\nDISPLAY: {1}", dbForm.FormName, dbForm.DisplayName); } break; case APP_ENTITIES.ROLES: TBL_MP_Master_Role dbRole = (new ServiceRoles()).GetRoleDBRecordByID(this.ENTITY_ID); if (dbRole != null) { txtDescription.Text = string.Format("ROLE NAME: {0}\nROLE NO.: {1}", dbRole.RoleName, dbRole.RoleNo); } break; case APP_ENTITIES.SALES_LEAD_ATTACHMENT: TBL_MP_CRM_SM_SalesLead_Attachment dbLeadAttachment = (new ServiceSalesLead()).GetSalesLeadAttachmentDBRecord(this.ENTITY_ID); if (dbLeadAttachment != null) { txtDescription.Text = string.Format("ATTACHMENT: {0}\nITEM:{1}\n{2}", dbLeadAttachment.Title.ToUpper(), dbLeadAttachment.TBL_MP_CRM_SM_SalesLead.LeadNo, dbLeadAttachment.TBL_MP_Master_UserList.Description1); } break; case APP_ENTITIES.SALES_ENQUIRY_ATTACHMENT: TBL_MP_CRM_SalesEnquiry_Attachments dbEnquiryAttachment = (new ServiceSalesEnquiry()).GetSalesEnquiryAttachmentDBRecord(this.ENTITY_ID); if (dbEnquiryAttachment != null) { txtDescription.Text = string.Format("ATTACHMENT: {0}\nITEM:{1}\n{2}", dbEnquiryAttachment.Title.ToUpper(), dbEnquiryAttachment.TBL_MP_CRM_SalesEnquiry.SalesEnquiry_No, dbEnquiryAttachment.TBL_MP_Master_UserList.Description1); } break; case APP_ENTITIES.SALES_QUOTATION_ATTACHMENT: TBL_MP_CRM_SalesQuotation_Attachments dbQuoteAttachment = (new ServiceSalesQuotation()).GetSalesQuotationAttachmentDBRecord(this.ENTITY_ID); if (dbQuoteAttachment != null) { txtDescription.Text = string.Format("ATTACHMENT: {0}\nITEM:{1}\n{2}", dbQuoteAttachment.Title.ToUpper(), dbQuoteAttachment.TBL_MP_CRM_SalesQuotation.Quotation_No, dbQuoteAttachment.TBL_MP_Master_UserList.Description1); } break; case APP_ENTITIES.SALES_ORDER_ATTACHMENT: TBL_MP_CRM_SalesOrder_Attachment dbOrderAttachment = (new ServiceSalesOrder()).GetSalesOrderAttachmentDBRecord(this.ENTITY_ID); if (dbOrderAttachment != null) { txtDescription.Text = string.Format("ATTACHMENT: {0}\nITEM:{1}\n{2}", dbOrderAttachment.Title.ToUpper(), dbOrderAttachment.TBL_MP_CRM_SalesOrder.SalesOrderNo, dbOrderAttachment.TBL_MP_Master_UserList.Description1); } break; case APP_ENTITIES.EMPLOYEES_ATTACHMENT: TBL_MP_Master_Employee_Attachment dbEmpAttachment = (new ServiceEmployee()).GetEmployeeAttachmentDBRecord(this.ENTITY_ID); if (dbEmpAttachment != null) { txtDescription.Text = string.Format("ATTACHMENT: {0}\nITEM:{1}\n{2}", dbEmpAttachment.Title.ToUpper(), dbEmpAttachment.TBL_MP_Master_Employee.EmployeeCode, dbEmpAttachment.TBL_MP_Master_UserList.Description1); } break; case APP_ENTITIES.CONTACTS: Tbl_MP_Master_PartyContact_Detail dbContact = (new ServiceContacts()).GetContactID(this.ENTITY_ID); if (dbContact != null) { txtDescription.Text = string.Format("Contact Person Name : {0}\nAddress:{1}\nMobile No:{2}\nAt.Telephone No:{3}\nEmail ID:{4}\n FAX NO:{5}", dbContact.ContactPersoneName, dbContact.Address, dbContact.MobileNo, dbContact.TelephoneNo, dbContact.EmailID, dbContact.FaxNo); } break; } } catch (Exception ex) { string errMessage = ex.Message; if (ex.InnerException != null) { errMessage += string.Format("\n{0}", ex.InnerException.Message); } MessageBox.Show(errMessage, "frmDelete::PopulateDescription", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
public void PopulateAdditionalInfo() { pictureBoxItemImage.Image = null; btnUploadPicture.Enabled = ButtonEnabled.False; txtCreatedBy.Text = txtModifiedBy.Text = lblBaseUOM.Text = lblPurchaseUOM.Text = string.Empty; try { TBL_MP_Master_Item item = (new ServiceInventoryItems()).GetItemDBRecord(this.SelectedItemID); if (item != null) { ServiceEmployee _serviceEmp = new ServiceEmployee(); if (item.CreatedBy != null) { txtCreatedBy.Text = string.Format("{0}\n{1}", ServiceEmployee.GetEmployeeNameByID((int)item.CreatedBy), item.CreatedDatetime.Value.ToString("dd MMM yy hh:mmtt")); } if (item.LastModifiedBy != null) { txtModifiedBy.Text = string.Format("{0}\n{1}", ServiceEmployee.GetEmployeeNameByID((int)item.LastModifiedBy), item.LastModifiedDate.Value.ToString("dd MMM yy hh:mmtt")); } List <SelectListItem> lstUOMs = (new ServiceMASTERS()).GetAllUOMs(); if (item.Fk_UserList_BaseUOM_ID != null) { lblBaseUOM.Text = string.Format("Base UOM : {0}", lstUOMs.Where(x => x.ID == item.Fk_UserList_BaseUOM_ID).FirstOrDefault().Description); } if (item.Fk_UserList_PurchaseUOM_ID != null) { lblPurchaseUOM.Text = string.Format("Purchase UOM : {0}", lstUOMs.Where(x => x.ID == item.Fk_UserList_PurchaseUOM_ID).FirstOrDefault().Description); } if (item.ImageFileName != null) { string filePath = string.Format("{0}{1}", AppCommon.GetInventoryItemImagePath(), item.ImageFileName); if (File.Exists(filePath)) { byte[] array = File.ReadAllBytes(filePath); Bitmap image; using (MemoryStream stream = new MemoryStream(array)) { image = new Bitmap(stream); } pictureBoxItemImage.Image = image; } } txtDeleteInfo.Text = string.Empty; bool isActive = (bool)item.IsActive; if (!isActive) { String empName = string.Empty; string delDate = string.Empty; if (item.DeletedBy != null) { empName = ServiceEmployee.GetEmployeeNameByID((int)item.DeletedBy); } if (item.DeletedBy != null) { delDate = item.DeleteDatetime.Value.ToString("dd MMM yy hh:mmtt"); } headerGroupDelete.ValuesPrimary.Heading = string.Format("DELETED : {0} DT. {1}", empName, delDate); txtDeleteInfo.Text = string.Format("{0}", item.DeleteRemarks); btnUploadPicture.Enabled = ButtonEnabled.False; } else { btnUploadPicture.Enabled = ButtonEnabled.True; headerGroupDelete.ValuesPrimary.Heading = string.Format("ACTIVE ITEM"); txtDeleteInfo.Text = string.Format("{0}", item.DeleteRemarks); } } } catch (Exception ex) { MessageBox.Show(ex.Message, "ctrlInventoryItemAdditionalInfo::PopulateAdditionalInfo", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
public System.Data.DataTable GenerateDesignBOQDataTableWithServices(System.Data.DataTable dt, BindingList <EnquiryBOQService> listServices, BindingList <EnquiryBOQItem> listItems) { try { // INSERT SERVICES COLUMN IN DATATABLE int stIndex = dt.Columns[COL_UOM_NAME].Ordinal; string strExpr = string.Empty; foreach (EnquiryBOQService item in listServices) { stIndex++; if (!dt.Columns.Contains(item.Description)) { dt.Columns.Add(new DataColumn() { ColumnName = item.Description, DataType = typeof(decimal), DefaultValue = 0 }); dt.Columns[item.Description].SetOrdinal(stIndex); } } dt.Columns[COL_TOTAL_QTY].SetOrdinal(dt.Columns.Count - 1); // INSERT ITEMS ROW IN DATATABLE foreach (EnquiryBOQItem item in listItems) { strExpr = string.Format("[{0}]=0 AND [{1}]={2}", COL_PARENT_ITEM_ID, COL_ITEM_ID, item.ID); DataRow[] result = dt.Select(strExpr); if (result.Count() == 0) { TBL_MP_Master_Item dbItem = (new ServiceInventoryItems()).GetItemDBRecord(item.ID); if (dbItem != null) { int newIndex = 0; if (dt.Rows.Count > 0) { newIndex = int.Parse(dt.AsEnumerable().Max(row => row[COL_INDEX]).ToString()); } newIndex++; string str = string.Format("MAX([{0}])", COL_SERIAL_NO_SYS); decimal newSerial = 0; if (dt.Rows.Count > 0) { newSerial = decimal.Parse((dt.Compute(str, string.Empty)).ToString()); } newSerial++; DataRow dtrow = dt.NewRow(); dtrow[COL_DEFAULT_QTY] = 0; dtrow[COL_INDEX] = newIndex; dtrow[COL_SERIAL_NO_SYS] = (int)newSerial; dtrow[COL_PARENT_ITEM_ID] = 0; dtrow[COL_HAS_SERVICES] = false; dtrow[COL_ITEM_ID] = item.ID; dtrow[COL_ITEM_CODE] = dbItem.ItemCode; dtrow[COL_HSN_CODE] = dbItem.HSNCode; dtrow[COL_ITEM_DESCRIPTION] = string.Format("{0}\n{1}", dbItem.Item_Name, dbItem.Long_Description); dtrow[COL_IS_ASSEMBLY] = dbItem.IsAssembly; //SET UOM ID & NAME if (dbItem.Fk_UserList_BaseUOM_ID != null) { List <SelectListItem> UOMs = (new ServiceMASTERS()).GetAllUOMs(); SelectListItem selUOM = UOMs.Where(x => x.ID == dbItem.Fk_UserList_BaseUOM_ID).FirstOrDefault(); if (selUOM != null) { dtrow[COL_UOM_ID] = selUOM.ID; dtrow[COL_UOM_NAME] = selUOM.Description; } } //SET SERCVICS COLUMNS QTY VALUE TO 0 foreach (EnquiryBOQService selService in listServices) { dtrow[selService.Description] = 0; } dtrow[COL_TOTAL_QTY] = 0; dt.Rows.Add(dtrow); } } } // REMOVE COLUMNS NOT FOUND IN SERVICES LIST string colsToRemove = string.Empty; stIndex = (dt.Columns[COL_UOM_NAME].Ordinal); stIndex++; for (int i = stIndex; i < dt.Columns.Count; i++) { string colName = dt.Columns[i].ColumnName; if (colName != COL_TOTAL_QTY) { EnquiryBOQService found = listServices.Where(x => x.Description == colName).FirstOrDefault(); if (found == null) { colsToRemove += colName + DefaultStringSeperator; } } } if (colsToRemove.EndsWith(DefaultStringSeperator.ToString())) { colsToRemove = colsToRemove.TrimEnd(DefaultStringSeperator); } if (colsToRemove != string.Empty) { string[] arrCols = colsToRemove.Split(DefaultStringSeperator); foreach (string s in arrCols) { dt.Columns.Remove(s); } } //// REMOVE ROWS NOT FOUND IN ITEMS LIST //string rowsToRemove = string.Empty; //foreach (DataRow dr in dt.Rows) //{ // int itemID = int.Parse(dr[COL_ITEM_ID].ToString()); // EnquiryBOQItem found = listItems.Where(x => x.ID == itemID).FirstOrDefault(); // if (found == null) // { // rowsToRemove += itemID.ToString() + DefaultStringSeperator; // } //} //if (rowsToRemove.EndsWith(DefaultStringSeperator.ToString())) //{ // rowsToRemove = rowsToRemove.TrimEnd(DefaultStringSeperator); //} //if (rowsToRemove != string.Empty) //{ // string[] arrRows = rowsToRemove.Split(DefaultStringSeperator); // foreach (string s in arrRows) // { // strExpr = string.Format("[{0}]=0 AND [{1}]={2}", COL_PARENT_ITEM_ID, COL_ITEM_ID, s); // DataRow delRow = dt.Select(strExpr).FirstOrDefault(); // if (delRow != null) // { // if ((bool)delRow[COL_IS_ASSEMBLY] == true) // { // strExpr = string.Format("[{0}]={1}", COL_PARENT_ITEM_ID, s); // DataRow[] childRows= dt.Select(strExpr); // for(int i=0;i<= childRows.GetUpperBound(0);i++) // dt.Rows.Remove(childRows[i]); // } // dt.Rows.Remove(delRow); // dt.AcceptChanges(); // } // } //} ////dt.Columns["TotalQty"].SetOrdinal(stIndex++); ////dt.Columns["UnitPrice"].SetOrdinal(stIndex++); ////dt.Columns["TotalPrice"].SetOrdinal(stIndex++); } catch (Exception ex) { MessageBox.Show(ex.Message, "ServiceSalesEnquiryBOQ::GenerateBOQDataTableWithServices", MessageBoxButtons.OK, MessageBoxIcon.Error); } return(dt); }
private void AddAssemblyChildItems(BindingList <MultiSelectListItem> selItems) { try { if (selItems.Count > 0) { ServiceSalesEnquiryBOQ _boqService = new ServiceSalesEnquiryBOQ(); foreach (MultiSelectListItem item in selItems) { string strSearch = string.Format("ItemID={0} AND ParentItemID={1}", item.ID, this.SelectedItemID); DataRow[] dr = BOQSheet.datatableBOQ.Select(strSearch); if (dr.Count() == 0) { TBL_MP_Master_Item dbItem = (new ServiceInventoryItems()).GetItemDBRecord(item.ID); if (dbItem != null) { var newIndex = int.Parse(BOQSheet.datatableBOQ.AsEnumerable().Max(row => row[_boqService.COL_INDEX]).ToString()); newIndex++; DataRow dtrow = BOQSheet.datatableBOQ.NewRow(); dtrow[_boqService.COL_INDEX] = newIndex; dtrow[_boqService.COL_SERIAL_NO_SYS] = GetNewSerialNoForChildItem(this.SelectedIndexID); dtrow[_boqService.COL_PARENT_ITEM_ID] = this.SelectedItemID; dtrow[_boqService.COL_HAS_SERVICES] = false; dtrow[_boqService.COL_ITEM_ID] = item.ID; dtrow[_boqService.COL_ITEM_CODE] = item.Code; dtrow[_boqService.COL_ITEM_DESCRIPTION] = item.Description; dtrow[_boqService.COL_IS_ASSEMBLY] = dbItem.IsAssembly; if (dbItem.Fk_UserList_BaseUOM_ID != null) { List <SelectListItem> UOMs = (new ServiceMASTERS()).GetAllUOMs(); SelectListItem selUOM = UOMs.Where(x => x.ID == dbItem.Fk_UserList_BaseUOM_ID).FirstOrDefault(); if (selUOM != null) { dtrow[_boqService.COL_UOM_ID] = selUOM.ID; dtrow[_boqService.COL_UOM_NAME] = selUOM.Description; } } //GET DEFAULT QUANTITY FROM ASSEMBLY CHILD ITEM TABLE dtrow[_boqService.COL_TOTAL_QTY] = (new ServiceInventoryItems()).GetDefaultQuantityofItemInAssembly(this.SelectedItemID, item.ID); dtrow[_boqService.COL_DEFAULT_QTY] = dtrow[_boqService.COL_TOTAL_QTY]; //SET SERCVICS COLUMNS QTY VALUE TO 0 foreach (EnquiryBOQService selService in BOQSheet.BOQ_SERVICES) { dtrow[selService.Description] = 0; } BOQSheet.datatableBOQ.Rows.Add(dtrow); } } } } } catch (Exception ex) { string errMessage = ex.Message; if (ex.InnerException != null) { errMessage += string.Format("\n{0}", ex.InnerException.Message); } MessageBox.Show(errMessage, "ControlSalesEnquiryDesignBOQ::AddAssemblyChildItems", MessageBoxButtons.OK, MessageBoxIcon.Error); } }