private void SaveBarCodeSettings(string BarCodeData) { int count = ObjCon.CountRecords(clsUtility.DBName + ".dbo.tblBarCodeSettings"); if (count == 0) { ObjCon.SetColumnData("BarCodeSetting", SqlDbType.NVarChar, BarCodeData); ObjCon.InsertData(clsUtility.DBName + ".dbo.tblBarCodeSettings", false); } else { int r = ObjCon.ExecuteNonQuery("Update " + clsUtility.DBName + ".dbo.tblBarCodeSettings set BarCodeSetting='" + BarCodeData + "'"); } }
private void dgvProductDetails_CellValueChanged(object sender, DataGridViewCellEventArgs e) { if (e.RowIndex >= 0 && e.ColumnIndex >= 0) { if (dgvProductDetails.Columns[e.ColumnIndex].Name == "EndUser") { try { int SubProductID = Convert.ToInt32(dgvProductDetails.Rows[e.RowIndex].Cells["SubProductID"].Value); decimal Rate = Convert.ToDecimal(dgvProductDetails.Rows[e.RowIndex].Cells["EndUser"].Value); int a = ObjDAL.ExecuteNonQuery("UPDATE " + clsUtility.DBName + ".[dbo].[tblProductWiseModelNo] SET EndUser="******" WHERE SubProductID=" + SubProductID); if (a > 0) { clsUtility.ShowInfoMessage("EndUser Price is Updated.."); } else { clsUtility.ShowInfoMessage("Unable to Update EndUser Price.."); } } catch (Exception ex) { clsUtility.ShowErrorMessage(ex.ToString()); } } } }
private void BackUpDatabase() { try { for (int i = 1; i <= 100; i++) { ObjThread.SetLoadingProgressPercent(i, 100); } //if (File.Exists(strBackUpPath + @"\" + DatabaseName + ".bak")) //{ // File.Delete(strBackUpPath + @"\" + DatabaseName + ".bak"); //} string sqlcmd = "BACKUP database " + DatabaseName + " TO DISK='" + strBackUpPath + @"\" + DatabaseName + ".bak' WITH INIT"; //added by aamir 26-06-2016 //File.Delete(strBackUpPath + @"\" + DatabaseName + ".bak"); //end int result = ObjDAL.ExecuteNonQuery(sqlcmd); if (result > 0 || result != -1) { WriteBackupLog(DatabaseName, "Backup Created Successfully"); clsUtility.ShowInfoMessage("BACKUP DATABASE successfully.", clsUtility.strProjectTitle); System.Diagnostics.Process.Start(strBackUpPath); } else { WriteBackupLog(DatabaseName, "Failed to create the backup."); clsUtility.ShowErrorMessage("Failed to create the backup.", clsUtility.strProjectTitle); } ObjThread.CloseLoadingDialog(); //System.Diagnostics.Process.Start("DatabaseBackupService.exe"); } catch (Exception ex) { WriteBackupLog(DatabaseName, "Backup DATABASE Faild."); ObjThread.CloseLoadingDialog(); clsUtility.ShowInfoMessage("BACKUP DATABASE Faild.", clsUtility.strProjectTitle); } }
private void SaveUserRights() { ObjCon.ExecuteNonQuery("Delete " + clsUtility.DBName + ".dbo.[tblStoreUserRights] where UserID = " + txtUserID.Text); dgvShopeDetails.EndEdit(); for (int i = 0; i < dgvShopeDetails.Rows.Count; i++) { if (Convert.ToBoolean(dgvShopeDetails.Rows[i].Cells["colCheck"].Value)) { string storeID = dgvShopeDetails.Rows[i].Cells["StoreID"].Value.ToString(); ObjCon.SetColumnData("UserID", SqlDbType.Int, txtUserID.Text); ObjCon.SetColumnData("StoreID", SqlDbType.Int, storeID); ObjCon.SetColumnData("CreatedOn", SqlDbType.DateTime, DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")); ObjCon.SetColumnData("CreatedBy", SqlDbType.Int, clsUtility.LoginID); ObjCon.InsertData(clsUtility.DBName + ".dbo.tblStoreUserRights", false); } } Clear(); clsUtility.ShowInfoMessage("User Shop rights have been saved.", clsUtility.strProjectTitle); }
private void btnAdd_Click(object sender, EventArgs e) { if (cmbGenerate.SelectedIndex == -1) { clsUtility.ShowInfoMessage("Please select the specification.", clsUtility.strProjectTitle); return; } else if (AnyRightCheck() == false) { CoreApp.clsUtility.ShowInfoMessage("Please select shop.", clsUtility.strProjectTitle); return; } StringBuilder bs = new StringBuilder(); dgvShopeDetails.EndEdit(); for (int i = 0; i < dgvShopeDetails.Rows.Count; i++) { if (Convert.ToBoolean(dgvShopeDetails.Rows[i].Cells["colCheck"].Value)) { string storeID = dgvShopeDetails.Rows[i].Cells["StoreID"].Value.ToString(); bs.Append(storeID); bs.Append(","); } } string StoreID = bs.ToString().Remove(bs.ToString().Length - 1, 1); ObjDAL.ExecuteNonQuery("Delete " + clsUtility.DBName + ".dbo.tblDashBoard "); ObjDAL.SetColumnData("Shopes", SqlDbType.NVarChar, StoreID); ObjDAL.SetColumnData("FromDate", SqlDbType.Date, dtpFromDate.Value.ToString("yyyy-MM-dd")); ObjDAL.SetColumnData("ToDate", SqlDbType.Date, dtpToDate.Value.ToString("yyyy-MM-dd")); ObjDAL.SetColumnData("Specification", SqlDbType.Int, cmbGenerate.SelectedIndex); ObjDAL.SetColumnData("RefreshRate", SqlDbType.Int, Convert.ToInt32(numericUpDown1.Value)); ObjDAL.InsertData("" + clsUtility.DBName + ".dbo.tblDashBoard", false); clsUtility.ShowInfoMessage("Dashboard settings has been saved.", clsUtility.strProjectTitle); this.Close(); }
private void button2_Click(object sender, EventArgs e) { DataTable dtFooterNote = ObjCon.ExecuteSelectStatement("select * FROM " + clsUtility.DBName + ".[dbo].[DefaultStoreSetting]"); if (dtFooterNote != null && dtFooterNote.Rows.Count > 0) // if data found for the PC thenupdate { ObjCon.ExecuteNonQuery("update " + clsUtility.DBName + ".dbo.DefaultStoreSetting set InvoiceFooterNote ='" + txtFooterNote.Text + "'"); clsUtility.ShowInfoMessage("Footer note has been updated.", clsUtility.strProjectTitle); } else { // else insert. ObjCon.SetColumnData("InvoiceFooterNote", SqlDbType.NVarChar, txtFooterNote.Text); int r = ObjCon.InsertData(clsUtility.DBName + ".[dbo].[DefaultStoreSetting]", false); if (r > 0) { clsUtility.ShowInfoMessage("Foorter note settings has been saved.", clsUtility.strProjectTitle); } lblmsg.Visible = false; } }
private void SaveRightsData(bool isEditMode) { if (isEditMode) { ObjCon.ExecuteNonQuery("DELETE " + clsUtility.DBName + ".[dbo].[tblUserRights] WHERE UserID=" + txtUserID.Text); } foreach (DataGridViewRow row in dgvUserRIghts.Rows) { bool RightFoud = false; if (row.Cells["View"].Value != DBNull.Value && Convert.ToBoolean(row.Cells["View"].Value)) { RightFoud = true; } else if (row.Cells["Save"].Value != DBNull.Value && Convert.ToBoolean(row.Cells["Save"].Value)) { RightFoud = true; } else if (row.Cells["Update"].Value != DBNull.Value && Convert.ToBoolean(row.Cells["Update"].Value)) { RightFoud = true; } else if (row.Cells["Delete"].Value != DBNull.Value && Convert.ToBoolean(row.Cells["Delete"].Value)) { RightFoud = true; } else if (row.Cells["Other"].Value != DBNull.Value && Convert.ToBoolean(row.Cells["Other"].Value)) { RightFoud = true; } // Only insert if right found. if (RightFoud) { RightFoud = false; bool IsView = false; bool IsSave = false; bool IsUpdate = false; bool IsDelete = false; bool IsOther = false; if (row.Cells["View"].Value != DBNull.Value && Convert.ToBoolean(row.Cells["View"].Value)) { IsView = true; } if (row.Cells["Save"].Value != DBNull.Value && Convert.ToBoolean(row.Cells["Save"].Value)) { IsSave = true; } if (row.Cells["Update"].Value != DBNull.Value && Convert.ToBoolean(row.Cells["Update"].Value)) { IsUpdate = true; } if (row.Cells["Delete"].Value != DBNull.Value && Convert.ToBoolean(row.Cells["Delete"].Value)) { IsDelete = true; } if (row.Cells["Other"].Value != DBNull.Value && Convert.ToBoolean(row.Cells["Other"].Value)) { IsOther = true; } ObjCon.SetColumnData("UserID", SqlDbType.Int, txtUserID.Text); ObjCon.SetColumnData("FormID", SqlDbType.Int, row.Cells["FormID"].Value.ToString()); ObjCon.SetColumnData("IsView", SqlDbType.Bit, IsView); ObjCon.SetColumnData("IsSave", SqlDbType.Bit, IsSave); ObjCon.SetColumnData("IsUpdate", SqlDbType.Bit, IsUpdate); ObjCon.SetColumnData("IsDelete", SqlDbType.Bit, IsDelete); ObjCon.SetColumnData("IsOther", SqlDbType.Bit, IsOther); ObjCon.SetColumnData("CreatedBy", SqlDbType.Int, clsUtility.LoginID); ObjCon.InsertData(clsUtility.DBName + ".dbo.tblUserRights", false); } } //ObjUtil.SetCommandButtonStatus(clsCommon.ButtonStatus.AfterSave, clsUtility.IsAdmin); if (isEditMode) { ObjUtil.SetCommandButtonStatus(clsCommon.ButtonStatus.AfterUpdate); clsUtility.ShowInfoMessage("User rights has been Updaetd Successfully.", clsUtility.strProjectTitle); isEdit = false; } else { ObjUtil.SetCommandButtonStatus(clsCommon.ButtonStatus.AfterSave); clsUtility.ShowInfoMessage("User rights has been Saved Successfully.", clsUtility.strProjectTitle); } ClearAll(); grpUserName.Enabled = false; grpRights.Enabled = false; }
private void btnAdd_Click_1(object sender, EventArgs e) { if (SalesValidation()) { dgvProductDetails.EndEdit(); // Before sales invocing make sure you have available qty for particular store string InvoiceDateTime = dtpSalesDate.Value.ToString("yyyy-MM-dd") + " " + DateTime.Now.ToString("HH:mm:ss"); GenerateInvoiceNumber(); #region SalesInvoiceDetails ObjDAL.SetColumnData("InvoiceNumber", SqlDbType.NVarChar, txtInvoiceNumber.Text); ObjDAL.SetColumnData("InvoiceDate", SqlDbType.DateTime, InvoiceDateTime); ObjDAL.SetColumnData("SubTotal", SqlDbType.Decimal, txtSubTotal.Text); ObjDAL.SetColumnData("Discount", SqlDbType.Decimal, txtDiscount.Text); ObjDAL.SetColumnData("Tax", SqlDbType.Decimal, txtDeliveryCharges.Text); ObjDAL.SetColumnData("GrandTotal", SqlDbType.Decimal, txtGrandTotal.Text); ObjDAL.SetColumnData("CreatedBy", SqlDbType.Int, clsUtility.LoginID); ObjDAL.SetColumnData("CustomerID", SqlDbType.Int, txtCustomerID.Text); ObjDAL.SetColumnData("SalesMan", SqlDbType.Int, txtEmpID.Text); ObjDAL.SetColumnData("ShopeID", SqlDbType.Int, cmbShop.SelectedValue.ToString()); ObjDAL.SetColumnData("PaymentMode", SqlDbType.NVarChar, lblPMode.Text); ObjDAL.SetColumnData("PaymentAutoID", SqlDbType.Int, Other_Forms.frmPayment.strPaymentAutoID); int InvoiceID = ObjDAL.InsertData(clsUtility.DBName + ".dbo.SalesInvoiceDetails", true); #endregion for (int i = 0; i < dgvProductDetails.Rows.Count; i++) { string Total = dgvProductDetails.Rows[i].Cells["Total"].Value.ToString(); string ProductID = dgvProductDetails.Rows[i].Cells["ProductID"].Value.ToString(); string QTY = dgvProductDetails.Rows[i].Cells["QTY"].Value.ToString(); string Rate = dgvProductDetails.Rows[i].Cells["Rate"].Value.ToString(); string ColorID = dgvProductDetails.Rows[i].Cells["ColorID"].Value.ToString(); string SizeID = dgvProductDetails.Rows[i].Cells["SizeID"].Value.ToString(); ObjDAL.SetColumnData("InvoiceID", SqlDbType.Int, InvoiceID); ObjDAL.SetColumnData("ProductID", SqlDbType.Int, ProductID); ObjDAL.SetColumnData("QTY", SqlDbType.Decimal, QTY); ObjDAL.SetColumnData("CreatedBy", SqlDbType.Int, clsUtility.LoginID); ObjDAL.SetColumnData("Rate", SqlDbType.Decimal, Rate); ObjDAL.SetColumnData("ColorID", SqlDbType.Int, ColorID); ObjDAL.SetColumnData("SizeID", SqlDbType.Int, SizeID); ObjDAL.InsertData(clsUtility.DBName + ".dbo.SalesDetails", false); ObjDAL.ExecuteNonQuery("UPDATE " + clsUtility.DBName + ".dbo.ProductStockColorSizeMaster " + "SET QTY=QTY-" + QTY + " WHERE ProductID=" + ProductID + " and StoreID=" + cmbShop.SelectedValue.ToString() + " AND ColorID=" + ColorID + " AND SizeID=" + SizeID); } clsUtility.ShowInfoMessage("Data has been saved successfully.", clsUtility.strProjectTitle); ClearAll(); Button button = (Button)sender; if (button.Name == "btnPrint") { Report.frmSalesInvoiceReport frmSalesInvoice = new Report.frmSalesInvoiceReport(); frmSalesInvoice.InvoiceID = InvoiceID; frmSalesInvoice.IsDirectPrint = true; frmSalesInvoice.Show(); } else { Report.frmSalesInvoiceReport frmSalesInvoice = new Report.frmSalesInvoiceReport(); frmSalesInvoice.InvoiceID = InvoiceID; frmSalesInvoice.IsDirectPrint = false; frmSalesInvoice.Show(); } } }
private string TransferStock() { string _BillNumber = ""; if (Bill_ID.Trim().Length == 0) { _BillNumber = GenerateBillNumber(); ObjDAL.SetColumnData("BillNo", SqlDbType.NVarChar, _BillNumber); ObjDAL.SetColumnData("FromStore", SqlDbType.Int, cmdFrom.SelectedValue); ObjDAL.SetColumnData("ToStore", SqlDbType.Int, cmdTo.SelectedValue); ObjDAL.SetColumnData("BillStatus", SqlDbType.NVarChar, lblBillStatus.Text); ObjDAL.SetColumnData("TotalQTY", SqlDbType.Int, txtTotalQTY.Text); ObjDAL.SetColumnData("BillDate", SqlDbType.Date, dtpSalesDate.Value.ToString("yyyy-MM-dd")); ObjDAL.SetColumnData("CreatedBy", SqlDbType.Int, clsUtility.LoginID); int TransferID = ObjDAL.InsertData(clsUtility.DBName + ".dbo.tblStoreTransferBillDetails", true); if (TransferID > 0) { for (int i = 0; i < dgvProductDetails.Rows.Count; i++) { string Total = dgvProductDetails.Rows[i].Cells["Total"].Value.ToString(); string ProductID = dgvProductDetails.Rows[i].Cells["ProductID"].Value.ToString(); string QTY = dgvProductDetails.Rows[i].Cells["BillQTY"].Value.ToString(); string Rate = dgvProductDetails.Rows[i].Cells["Rate"].Value.ToString(); string ColorID = dgvProductDetails.Rows[i].Cells["ColorID"].Value.ToString(); string SizeID = dgvProductDetails.Rows[i].Cells["SizeID"].Value.ToString(); string BarcodeNo = dgvProductDetails.Rows[i].Cells["BarcodeNo"].Value.ToString(); string SubProductID = dgvProductDetails.Rows[i].Cells["SubProductID"].Value.ToString(); ObjDAL.SetColumnData("StoreBillDetailsID", SqlDbType.Int, TransferID); ObjDAL.SetColumnData("ProductID", SqlDbType.Int, ProductID); ObjDAL.SetColumnData("Barcode", SqlDbType.NVarChar, BarcodeNo); ObjDAL.SetColumnData("SubProductID", SqlDbType.Int, SubProductID); ObjDAL.SetColumnData("Rate", SqlDbType.Decimal, Rate); ObjDAL.SetColumnData("BillQTY", SqlDbType.Int, QTY); ObjDAL.SetColumnData("ColorID", SqlDbType.Int, ColorID); ObjDAL.SetColumnData("SizeID", SqlDbType.Int, SizeID); ObjDAL.SetColumnData("Total", SqlDbType.Decimal, Total); ObjDAL.SetColumnData("CreatedBy", SqlDbType.Int, clsUtility.LoginID); ObjDAL.InsertData(clsUtility.DBName + ".dbo.tblStoreTransferItemDetails", false); } clsUtility.ShowInfoMessage("Item has been transferd to selected store.", clsUtility.strProjectTitle); } } else { _BillNumber = txtInvoiceNumber.Text; ObjDAL.UpdateColumnData("UpdatedOn", SqlDbType.DateTime, DateTime.Now); ObjDAL.UpdateColumnData("UpdatedBy", SqlDbType.Int, clsUtility.LoginID); ObjDAL.UpdateData(clsUtility.DBName + ".dbo.tblStoreTransferBillDetails", "StoreTransferID='" + Bill_ID + "'"); ObjDAL.ExecuteNonQuery("Delete " + clsUtility.DBName + ".dbo.tblStoreTransferItemDetails WHERE StoreBillDetailsID=" + Bill_ID); int pBillQTY = 0; for (int i = 0; i < dgvProductDetails.Rows.Count; i++) { string Total = dgvProductDetails.Rows[i].Cells["Total"].Value.ToString(); string ProductID = dgvProductDetails.Rows[i].Cells["ProductID"].Value.ToString(); string QTY = dgvProductDetails.Rows[i].Cells["BillQTY"].Value.ToString(); pBillQTY += Convert.ToInt32(QTY); string Rate = dgvProductDetails.Rows[i].Cells["Rate"].Value.ToString(); string ColorID = dgvProductDetails.Rows[i].Cells["ColorID"].Value.ToString(); string SizeID = dgvProductDetails.Rows[i].Cells["SizeID"].Value.ToString(); string BarcodeNo = dgvProductDetails.Rows[i].Cells["BarcodeNo"].Value.ToString(); string SubProductID = dgvProductDetails.Rows[i].Cells["SubProductID"].Value.ToString(); ObjDAL.SetColumnData("StoreBillDetailsID", SqlDbType.Int, Bill_ID); ObjDAL.SetColumnData("ProductID", SqlDbType.Int, ProductID); ObjDAL.SetColumnData("Barcode", SqlDbType.NVarChar, BarcodeNo); ObjDAL.SetColumnData("SubProductID", SqlDbType.Int, SubProductID); ObjDAL.SetColumnData("Rate", SqlDbType.Decimal, Rate); ObjDAL.SetColumnData("BillQTY", SqlDbType.Int, QTY); ObjDAL.SetColumnData("ColorID", SqlDbType.Int, ColorID); ObjDAL.SetColumnData("SizeID", SqlDbType.Int, SizeID); ObjDAL.SetColumnData("Total", SqlDbType.Decimal, Total); ObjDAL.SetColumnData("CreatedBy", SqlDbType.Int, clsUtility.LoginID); ObjDAL.InsertData(clsUtility.DBName + ".dbo.tblStoreTransferItemDetails", false); } ObjDAL.UpdateColumnData("TotalQTY", SqlDbType.Int, pBillQTY); ObjDAL.UpdateColumnData("UpdatedOn", SqlDbType.DateTime, DateTime.Now); ObjDAL.UpdateColumnData("UpdatedBy", SqlDbType.Int, clsUtility.LoginID); ObjDAL.UpdateData(clsUtility.DBName + ".dbo.tblStoreTransferBillDetails", "StoreTransferID='" + Bill_ID + "'"); clsUtility.ShowInfoMessage("Item has been transferd to selected store.", clsUtility.strProjectTitle); } return(_BillNumber); }
private void button1_Click(object sender, EventArgs e) { bool result = clsUtility.ShowQuestionMessage("Are you sure, you want to print the barcode for all QTY ?", clsUtility.strProjectTitle); if (result == false) { return; } PrintDialog pd = new PrintDialog(); PrintDocument doc = new PrintDocument(); doc.PrintPage += Doc_PrintPage; pd.Document = doc; if (pd.ShowDialog() == DialogResult.OK) { for (int i = 0; i < dgvProductDetails.Rows.Count; i++) { if (dgvProductDetails.Rows[i].Cells["colCHeck"].Value != DBNull.Value && Convert.ToBoolean(dgvProductDetails.Rows[i].Cells["colCHeck"].Value)) { _PrintRowData = dgvProductDetails.Rows[i]; int PID = Convert.ToInt32(dgvProductDetails.Rows[i].Cells["ColProductID"].Value); int QTY = Convert.ToInt32(dgvProductDetails.Rows[i].Cells["ColQTY"].Value); int SizeID = Convert.ToInt32(dgvProductDetails.Rows[i].Cells["SizeID"].Value); int ColorID = Convert.ToInt32(dgvProductDetails.Rows[i].Cells["ColColorID"].Value); // check if barcode number exist DataTable dtBarCodeNumber = ObjCon.ExecuteSelectStatement("select BarcodeNo from " + clsUtility.DBName + ".dbo.ProductStockColorSizeMaster where ProductID=" + PID + " and ColorID=" + ColorID + " and SizeID=" + SizeID); if (ObjUtil.ValidateTable(dtBarCodeNumber)) { if (dtBarCodeNumber.Rows[0]["BarcodeNo"] != DBNull.Value && dtBarCodeNumber.Rows[0]["BarcodeNo"].ToString().Length >= 0) { _Current_BarCodeNumber = dtBarCodeNumber.Rows[0]["BarcodeNo"].ToString(); } else { _Current_BarCodeNumber = GetBarcodeNumber(); // update the bar code in ProductStockColorSizeMaster ( main stock table) string strUpdat = "UPDATE " + clsUtility.DBName + ".dbo.ProductStockColorSizeMaster SET BarcodeNo='" + _Current_BarCodeNumber + "' WHERE ProductID=" + PID + " AND ColorID=" + ColorID + " AND SizeID=" + SizeID; ObjCon.ExecuteNonQuery(strUpdat); // update the bar code in [ProductStockMaster] string strUpdate2 = "UPDATE " + clsUtility.DBName + ".[dbo].[ProductStockMaster] SET BarcodeNo='" + _Current_BarCodeNumber + "' WHERE ProductID=" + PID + " AND PurchaseInvoiceID=" + CurrentPurchaseInvoiceID + " and SizeID=" + SizeID + " AND ColorID=" + ColorID; ObjCon.ExecuteNonQuery(strUpdate2); } } else { _Current_BarCodeNumber = GetBarcodeNumber(); string strUpdat = "UPDATE " + clsUtility.DBName + ".dbo.ProductStockColorSizeMaster " + " SET BarcodeNo='" + _Current_BarCodeNumber + "' WHERE ProductID=" + PID + " AND ColorID=" + ColorID + " AND SizeID=" + SizeID; ObjCon.ExecuteNonQuery(strUpdat); } for (int Q = 0; Q < QTY; Q++) { doc.Print(); } } } } clsUtility.ShowInfoMessage("Operation completed !", clsUtility.strProjectTitle); }
private void UpdateProductStockMasterStatus(int QTY, int ProductStockID) { int a = ObjDAL.ExecuteNonQuery("UPDATE " + clsUtility.DBName + ".dbo.ProductStockMaster SET PrintCount+=" + QTY + ",UpdatedOn=GETDATE(),UpdatedBy=" + clsUtility.LoginID + " WHERE ProductStockID=" + ProductStockID); }