public void SaveInvoice() { StringBuilder sbQry = new StringBuilder(); clsDB oDB = new clsDB(); try { oDB.Connect(); oDB.BeginTran(); foreach (Item ItemObj in this.ItemObject) { sbQry.AppendLine("Insert Into Invoice(TinNo,PanNo,BillNo,InvoiceDate,InvoiceDateTime,Address,PoNo"); sbQry.AppendLine(",ItemDesc,Qty,Rate,Amount,Vat,GrandTotalWords) Values('" + TinNo + "','" + PanNo + "'"); sbQry.AppendLine(",'" + BillNo + "','" + DateTime.Now.ToString("dd-MMM-yyyy") + "',Getdate(),'" + Address + "'"); sbQry.AppendLine(",'" + PoNo + "','" + ItemObj.ItemDesc + "'," + ItemObj.ItemQty + "," + ItemObj.Rate + "," + ItemObj.Amount + ",'" + Vat + "','" + GrandTotalInWords + "')"); oDB.ExecuteNonQuery(sbQry.ToString()); sbQry.Length = 0; } oDB.CommitTran(); } catch (Exception ex) { oDB.RollBackTran(); throw ex; } finally { sbQry = null; oDB.DisConnect(); oDB = null; } }
public void InsertLayCutHD() { string errMsg = ""; clsDB obj = new clsDB(); SortedList sl = new SortedList(); Int32 i = 0; try { sl.Add("@LayerBatchNo", LayerBatchNo); sl.Add("@compcode", compcode); sl.Add("@loccode", loccode); sl.Add("@BunNoMethod", BunNoMethod); sl.Add("@CutDate", CutDate); sl.Add("@JobOrderNo", JobOrderNo); sl.Add("@StyleCode", StyleCode); sl.Add("@AVGConsumption", AVGConsumption); sl.Add("@PCSPerBundle", PCSPerBundle); sl.Add("@MerchandiserCode", MerchandiserCode); sl.Add("@CuttingMasterCode", CuttingMasterCode); sl.Add("@QCHeadCode", QCHeadCode); sl.Add("@BundleStartNo", BundleStartNo); sl.Add("@BundleEndNo", BundleEndNo); sl.Add("@createdby", createdby); sl.Add("@modifiedby", modifiedby); sl.Add("@createdDate", createdDate); sl.Add("@modifiedDate", modifiedDate); sl.Add("@TransferFlag", TransferFlag); sl.Add("@DeletedSataus", DeletedSataus); sl.Add("@CanGenerateBundle", CanGenerateBundle); sl.Add("@BundleCreated", BundleCreated); i = obj.ExecuteNonQuery("iLayerCutHD", sl); } catch (Exception ex) { errMsg = ex.Message; } finally { obj = null; } }
public void InsertLayCutBundle() { string errMsg = ""; clsDB obj = new clsDB(); SortedList sl = new SortedList(); Int32 i = 0; try { sl.Add("@compcode", compcode); sl.Add("@loccode", loccode); sl.Add("@LayerBatchNo", LayerBatchNo); sl.Add("@CutDate", CutDate); sl.Add("@DTLSlno", DTLSlno); sl.Add("@BundleSlno", BundleSlno); sl.Add("@BunSubSlno", BunSubSlno); sl.Add("@BunLetter", BunLetter); sl.Add("@BunNoWOLetter", BunNoWoletter); sl.Add("@BundleNo", BundleNo); sl.Add("@ProductNo", ProductNo); sl.Add("@StyleCode", StyleCode); sl.Add("@FabColor", FabColor); sl.Add("@bunIntno", bunIntNo); sl.Add("@bunqty", bunQty); sl.Add("@bunRange", bunRange); sl.Add("@createdby", createdby); sl.Add("@modifiedby", modifiedby); sl.Add("@createdDate", createdDate); sl.Add("@modifiedDate", modifiedDate); sl.Add("@TransferFlag", TransferFlag); i = obj.ExecuteNonQuery("iLayerCutBundle", sl); } catch (Exception ex) { errMsg = ex.Message; } finally { obj = null; } }
public void InsertLayCutDTL() { string errMsg = ""; clsDB obj = new clsDB(); SortedList sl = new SortedList(); Int32 i = 0; try { sl.Add("@compcode", compcode); sl.Add("@loccode", loccode); sl.Add("@LayerBatchNo", LayerBatchNo); sl.Add("@CutDate", CutDate); sl.Add("@SlNo", SlNo); sl.Add("@FabricCode", FabricCode); sl.Add("@RollNumber", RollNumber); sl.Add("@FabColor", FabColor); sl.Add("@FabricInMTR", FabricInMTR); sl.Add("@PcsToMake", PcsToMake); sl.Add("@OrdQty", OrdQty); sl.Add("@Average", Average); sl.Add("@ExtraQty", ExtraQty); sl.Add("@ConsumedFabric", ConsumedFabric); sl.Add("@BalanceFabric", BalanceFabric); sl.Add("@createdby", createdby); sl.Add("@modifiedby", modifiedby); sl.Add("@createdDate", createdDate); sl.Add("@modifiedDate", modifiedDate); sl.Add("@TransferFlag", TransferFlag); sl.Add("@sc", StyleCode); i = obj.ExecuteNonQuery("iLayerCutDTL", sl); } catch (Exception ex) { errMsg = ex.Message; } finally { obj = null; } }
public void InsertStyle() { string errMsg = ""; clsDB obj = new clsDB(); SortedList sl = new SortedList(); Int32 i = 0; try { sl.Add("@pubStyleID", pubStyleID); sl.Add("@desdate", desdate); sl.Add("@sc", sc); sl.Add("@sn", sn); sl.Add("@dsgid", dsgid); sl.Add("@catid", catid); sl.Add("@subcId", subcId); sl.Add("@pcost", pcost); sl.Add("@srate", srate); sl.Add("@prodInstr", prodInstr); sl.Add("@mfbk", mfbk); sl.Add("@SizeTypeID", subcattype); sl.Add("@FabWidthId", fabwidthid); sl.Add("@WidthSize", fabsize); sl.Add("@PcsPerBundle", pcsperbundle); sl.Add("@RatioFormatCode", RatioFormatCode); sl.Add("@CFid", CFid); sl.Add("@cusid", cusid); sl.Add("@CusPoNo", CusPoNo); sl.Add("@OrderQty", OrderQty); sl.Add("@ShippingTargetDate", ShippingTargetDate); i = obj.ExecuteNonQuery("iStyle", sl); } catch (Exception ex) { errMsg = ex.Message; } finally { obj = null; } }
public void SetStartEndBundleNumberForSeries(decimal BundleEndNo, string stcode) { string errMsg = ""; clsDB obj = new clsDB(); SortedList sl = new SortedList(); try { sl.Add("@BundleEndNo", BundleEndNo); sl.Add("@sercode", stcode); obj.ExecuteNonQuery("uLayerCutHDStartNo", sl); } catch (Exception ex) { errMsg = ex.Message; } finally { obj = null; } }
public void DelLayBundle(int LayBatNo, string StyleCode) { string errMsg = ""; clsDB obj = new clsDB(); SortedList sl = new SortedList(); try { sl.Add("@StyleCode", StyleCode); sl.Add("@LayerBatchNo", LayBatNo); obj.ExecuteNonQuery("dLayerCutBundle", sl); } catch (Exception ex) { errMsg = ex.Message; } finally { obj = null; } }
public void UpdateBundleFlagStatus(Int32 LayBNumber, string stylecode) { string errMsg = ""; clsDB obj = new clsDB(); SortedList sl = new SortedList(); try { sl.Add("@LBno", LayBNumber); sl.Add("@sc", stylecode); obj.ExecuteNonQuery("uBundleFlagStatus", sl); } catch (Exception ex) { errMsg = ex.Message; } finally { obj = null; } }
public void UpdateLastBundleNumber(decimal LBNumber, string stcode) { string errMsg = ""; clsDB obj = new clsDB(); SortedList sl = new SortedList(); try { sl.Add("@bunNo", LBNumber); sl.Add("@scode", stcode); obj.ExecuteNonQuery("uBundlebySerCode", sl); } catch (Exception ex) { errMsg = ex.Message; } finally { obj = null; } }
public int DeleteItem() { StringBuilder sbQry = new StringBuilder(); clsDB oDB = new clsDB(); try { oDB.Connect(); sbQry.Append("Delete From Item Where ItemDesc = '" + ItemDesc + "'"); int iCount = oDB.ExecuteNonQuery(sbQry.ToString()); return(iCount); } catch (Exception ex) { throw ex; } finally { sbQry = null; oDB.DisConnect(); oDB = null; } }
public int SaveHeader() { StringBuilder sbQry = new StringBuilder(); clsDB oDB = new clsDB(); try { oDB.Connect(); string sMsg = "OK"; sbQry.Append("Select Count(*) From mHeader Where Id = '" + HeaderId + "'"); int iCount = (int)oDB.ExecuteScalar(sbQry.ToString()); sbQry.Length = 0; //If already exist then update otherwise insert if (iCount > 0) { sbQry.Append("Update mHeader Set Header1='" + Header1 + "',Header2='" + Header2 + "',Header3='" + Header3 + "',Header4='" + Header4 + "' Where Id = '" + HeaderId + "'"); } else { sbQry.Append("Insert Into mHeader(Id,Header1,Header2,Header3,Header4) Values('" + HeaderId + "','" + Header1 + "','" + Header2 + "','" + Header3 + "','" + Header4 + "')"); } iCount = oDB.ExecuteNonQuery(sbQry.ToString()); return(iCount); } catch (Exception ex) { throw ex; } finally { sbQry = null; oDB.DisConnect(); oDB = null; } }
public string SaveItem() { StringBuilder sbQry = new StringBuilder(); clsDB oDB = new clsDB(); try { oDB.Connect(); string sMsg = "OK"; sbQry.Append("Select Count(*) From Item Where ItemDesc = '" + ItemDesc + "'"); int iCount = (int)oDB.ExecuteScalar(sbQry.ToString()); sbQry.Length = 0; //If already exist then update otherwise insert if (iCount > 0) { sMsg = "Item already exist!!"; } else { sbQry.Append("Insert Into Item(ItemDesc) Values('" + ItemDesc + "')"); } iCount = oDB.ExecuteNonQuery(sbQry.ToString()); return(sMsg); } catch (Exception ex) { throw ex; } finally { sbQry = null; oDB.DisConnect(); oDB = null; } }
public int SaveAddress() { StringBuilder sbQry = new StringBuilder(); clsDB oDB = new clsDB(); try { oDB.Connect(); string sMsg = "OK"; sbQry.Append("Select Count(*) From mAddress Where Id = '" + AddressId + "'"); int iCount = (int)oDB.ExecuteScalar(sbQry.ToString()); sbQry.Length = 0; //If already exist then update otherwise insert if (iCount > 0) { sbQry.Append("Update mAddress Set Address1='" + Address1 + "',Address2='" + Address2 + "',Address3='" + Address3 + "',Address4='" + Address4 + "' Where Id = '" + AddressId + "'"); } else { sbQry.Append("Insert Into mAddress(Id,Address1,Address2,Address3,Address4) Values('" + AddressId + "','" + Address1 + "','" + Address2 + "','" + Address3 + "','" + Address4 + "')"); } iCount = oDB.ExecuteNonQuery(sbQry.ToString()); return(iCount); } catch (Exception ex) { throw ex; } finally { sbQry = null; oDB.DisConnect(); oDB = null; } }
public Boolean UploadToDB() { try { CustomCode u = new CustomCode(); Int64 assyID = -1; if (m_lstObsoleteParts.Count > 0 || m_lstUndefinedPNs.Count > 0) { return(false); } m_errMsg.Clear(); //First, we need to make an entry in table asyBOM so we can get the DB ID of the Assy xDB = new clsDB(); cmd = new SqlCommand(); List <SqlParameter> ps = new List <SqlParameter>(); string assyDesc = "ASSY," + m_topLevelName; ps.Add(new SqlParameter("@" + DBK.strNAME, m_topLevelName)); ps.Add(new SqlParameter("@" + DBK.strASSYPARTNUMBER, m_assyPN)); ps.Add(new SqlParameter("@" + DBK.strREVISION, m_assyRev)); ps.Add(new SqlParameter("@" + DBK.intBOMREV, m_bomRev)); ps.Add(new SqlParameter("@" + DBK.strDESCRIPTION, assyDesc)); ps.Add(new SqlParameter("@intMajor", u.getMajorRev(m_assyRev))); ps.Add(new SqlParameter("@intMinor", u.getMinorRev(m_assyRev))); ps.Add(new SqlParameter("@" + DBK.keyUPLOADEDBY, u.getUserDBID())); ps.Add(new SqlParameter("@" + DBK.keyASSYBU, u.getUserdBUID())); ps.Add(new SqlParameter("@" + DBK.keyREASONFORREV, 1)); ps.Add(new SqlParameter("@" + DBK.keyASSYSTATUS, 1)); ps[ps.Count - 1].Direction = System.Data.ParameterDirection.InputOutput; ps.Add(new SqlParameter("@" + DBK.ID, -1)); ps[ps.Count - 1].Direction = System.Data.ParameterDirection.Output; using (xDB.OpenConnection()) { xDB.ExecuteSP(DBK.SP.spUPSERTASSYBOMENTRY, ps, clsDB.SPExMode.NONQUERY, ref cmd); if (int.Parse(cmd.Parameters["@" + DBK.keyASSYSTATUS].Value.ToString()) == 1) { assyID = Int64.Parse(cmd.Parameters["@" + DBK.ID].Value.ToString()); //Delete this ASSY ID From the database List <SqlParameter> tmpLstP = new List <SqlParameter>(); tmpLstP.Add(new SqlParameter("@" + DBK.keyASSY, assyID)); SqlCommand tmpCmd = new SqlCommand(); using (xDB.OpenConnection()) { xDB.ExecuteSP(DBK.SP.spDELETEASSYBOMPARTS, tmpLstP, clsDB.SPExMode.NONQUERY, ref tmpCmd); } StringBuilder sqlStr = new StringBuilder(); sqlStr.Append("INSERT INTO " + DBK.asyBOMPARTS + " (" + DBK.keyASSY + ", " + DBK.keyPN + ", " + DBK.strREFDES + ", " + DBK.strBOMNOTES + ", " + DBK.intQTY + ") VALUES "); //The values we will insert are in m_BOM foreach (string assyPNKy in m_BOM.Keys) { string abk = assyPNKy; foreach (string PNKy in m_BOM[assyPNKy].Keys) { AssyBomLineItem x = m_BOM[assyPNKy][PNKy]; string bomNotes = x.BOMNotes; if (bomNotes == "" || bomNotes == "-") { bomNotes = "''"; } sqlStr.Append("(" + assyID + ", " + x.PNID.ToString() + ", " + "'" + x.RefDes + "', " + bomNotes + ", " + x.Qty.ToString() + "),"); } } //Remove the last comma sqlStr.Remove(sqlStr.Length - 1, 1); cmd.Parameters.Clear(); using (xDB.OpenConnection()) { if (xDB.ExecuteNonQuery(sqlStr.ToString())) { if (xDB.NAffectedRows > 0) { return(true); } else { m_errMsg.Append("Executed following query without errors:" + sqlStr + AAAK.vbCRLF + "...but no rows were affected by the Statement. Please report this bug."); return(false); } } else { m_errMsg.Append("Method UploadToDB: Unable to execute Nonquery: " + sqlStr + AAAK.vbCRLF + xDB.ErrMsg); return(false); } } } else { m_errMsg.Append(m_topLevelName + " Revision " + m_assyRev + " BOM Revision " + m_bomRev + "is RELEASED. You cannot upload a new BOM if it's status is RELEASED." + AAAK.vbCRLF + "If you want to upload a new BOM, you must change the Assembly and/or BOM revision."); return(false); } } } catch (Exception ex) { m_errMsg.Append(ex.Message + AAAK.vbCRLF + ex.StackTrace); return(false); } }