private void toolStripMenuItem2_Click(object sender, EventArgs e) { var us = new User(); var userID = MainWindow.LoggedinId; us.LoadByPrimaryKey(userID); var dr = gridView1.GetFocusedDataRow(); if (dr == null) return; int tranId = Convert.ToInt32(dr["ID"]); var rec = new ReceiveDoc(); rec.LoadByPrimaryKey(tranId); var iss = new IssueDoc(); iss.GetIssueByBatchAndId(rec.ItemID, rec.BatchNo, rec.ID); _dtDate.CustomFormat = "MM/dd/yyyy"; DateTime dtCurrent = ConvertDate.DateConverter(_dtDate.Text); if ((rec.Date.Year != dtCurrent.Year && rec.Date.Month < 11) || (iss.RowCount != 0)) { XtraMessageBox.Show("Unable to Delete, This Transaction has been processed. Try Loss and Adjustment.", "Unable to Delete", MessageBoxButtons.YesNo, MessageBoxIcon.Question); } else { if ( XtraMessageBox.Show( "Are You Sure, You want to delete this Transaction? You will not be able to restore this data.", "Confirmation", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { //AddDeletedRecieveDoc(rec); rec.MarkAsDeleted(); rec.Save(); _dtDate.Value = DateTime.Now; _dtDate.CustomFormat = "MM/dd/yyyy"; dtCurrent = ConvertDate.DateConverter(_dtDate.Text); int yr = ((dtCurrent.Month > 10) ? dtCurrent.Year : dtCurrent.Year - 1); DateTime dt1 = new DateTime(yr, 11, 1); DateTime dt2 = new DateTime(dtCurrent.Year, dtCurrent.Month, dtCurrent.Day); DataTable dtRec = rec.GetTransactionByDateRange(Convert.ToInt32(cboStores.EditValue), dt1, dt2); gridReceives.DataSource = dtRec; } } }
private void gridView1_DoubleClick(object sender, EventArgs e) { DataRow dr = gridView1.GetFocusedDataRow(); if (dr == null) return; int tranId = Convert.ToInt32(dr["ID"]); ReceiveDoc rec = new ReceiveDoc(); rec.LoadByPrimaryKey(tranId); _dtDate.Value = DateTime.Now; _dtDate.CustomFormat = "MM/dd/yyyy"; IssueDoc iss = new IssueDoc(); iss.GetIssueByBatchAndId(rec.ItemID, rec.BatchNo, rec.ID); DateTime dtCurrent = ConvertDate.DateConverter(_dtDate.Text); if ((rec.Date.Year != dtCurrent.Year && rec.Date.Month < 11) || (iss.RowCount != 0)) { //XtraMessageBox.Show("Unable to edit, This Transaction has been processed. Try Loss and Adjustment.", "Unable to Edit", MessageBoxButtons.OK, MessageBoxIcon.Stop); EditReceive edRec = new EditReceive(tranId, true); MainWindow.ShowForms(edRec); } else { EditReceive edRec = new EditReceive(tranId, false); MainWindow.ShowForms(edRec); } }
private void toolStripMenuItem1_Click(object sender, EventArgs e) { var us = new User(); var userID = MainWindow.LoggedinId; us.LoadByPrimaryKey(userID); var dr = gridView1.GetFocusedDataRow(); if (dr == null) return; //if (us.UserName != "admin") //{ // XtraMessageBox.Show("You don't have the privilege to update reference number!", "Caution"); // return; //} int tranId = Convert.ToInt32(dr["ID"]); var rec = new ReceiveDoc(); var iss = new IssueDoc(); var dis = new Disposal(); rec.LoadByPrimaryKey(tranId); iss.GetIssueByBatchAndId(rec.ItemID, rec.BatchNo, rec.ID); _dtDate.Value = DateTime.Now; _dtDate.CustomFormat = "MM/dd/yyyy"; //if (iss.RowCount == 0) //{ if ((iss.RowCount != 0) && (iss.RecievDocID != null && iss.RecievDocID == rec.ID)) { var edRec = new EditReceive(tranId, true); MainWindow.ShowForms(edRec); } //} else if(iss.RowCount ==0) { var edRec = new EditReceive(tranId, false); MainWindow.ShowForms(edRec); } }
/// <summary> /// After doing validation, the receive information is saved to the database. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnSave_Click(object sender, EventArgs e) { string valid = ValidateFields(); if ( valid == "true") { if (XtraMessageBox.Show("Are You Sure, You want to save this Transaction?", "Confirmation", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { ReceiveDoc rec = new ReceiveDoc(); IssueDoc iss =new IssueDoc(); ProgramProduct pp = new ProgramProduct(); rec.LoadByPrimaryKey(_tranId); iss.GetIssueByBatchAndId(rec.ItemID, rec.BatchNo, rec.ID); rec.RefNo = txtRefNo.Text; int previousprogid = rec.SubProgramID; dtRecDate.CustomFormat = "MM/dd/yyyy"; string dtValid = ""; try { rec.Date = Convert.ToDateTime(txtDate.Text); } catch { string year = ""; if (Convert.ToInt32(txtDate.Text.Substring(0, 2)) == 13) { dtValid = txtDate.Text; year = dtValid.Substring(dtValid.Length - 4, 4); rec.Date = Convert.ToDateTime("12/30/" + year); } else if (Convert.ToInt32(txtDate.Text.Substring(0, 2)) == 2) { dtValid = txtDate.Text; year = dtValid.Substring(dtValid.Length - 4, 4); rec.Date = Convert.ToDateTime("2/28/" + year); } } if ((iss.RowCount != 0) && (iss.RecievDocID != null && iss.RecievDocID == rec.ID)) { rec.BatchNo = txtBatchNo.Text; rec.ExpDate = dtExpiryDate.Value; rec.Remark = txtRemark.Text; rec.ReceivedBy = txtReceivedBy.Text; rec.SupplierID = Convert.ToInt32(cboSupplier.SelectedValue); rec.UnitID = VisibilitySetting.HandleUnits==1 ? 0 : Convert.ToInt32(lkItemUnit.EditValue); rec.StoreID = Convert.ToInt32(cboStores.SelectedValue); pp.LoadByNewProgramIdAndItemId(Convert.ToInt32(rec.ItemID), Convert.ToInt32(lkPrograms.EditValue)); if (pp.RowCount == 1) { rec.SubProgramID = Convert.ToInt32(lkPrograms.EditValue); pp.ProgramID = Convert.ToInt32(lkPrograms.EditValue); pp.ItemID = Convert.ToInt32(rec.ItemID); pp.Save(); } else if (pp.RowCount == 0) { rec.SubProgramID = Convert.ToInt32(lkPrograms.EditValue); pp.AddNew(); pp.ProgramID = rec.SubProgramID; pp.ItemID = Convert.ToInt32(rec.ItemID); pp.Save(); } rec.Out = false; rec.Save(); XtraMessageBox.Show("Transaction Succsfully Saved!", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information); this.Close(); } else if (iss.RowCount == 0) { rec.BatchNo = txtBatchNo.Text; rec.ExpDate = dtExpiryDate.Value; rec.Remark = txtRemark.Text; rec.ReceivedBy = txtReceivedBy.Text; rec.NoOfPack = Convert.ToInt32(txtPack.Text); rec.QtyPerPack = Convert.ToInt32(txtQtyPack.Text); rec.Quantity = Convert.ToInt32(txtPack.Text) * Convert.ToInt32(txtQtyPack.Text); rec.QuantityLeft = Convert.ToInt32(txtPack.Text) * Convert.ToInt32(txtQtyPack.Text); rec.Out = false; rec.StoreID = Convert.ToInt32(cboStores.SelectedValue); rec.SupplierID = Convert.ToInt32(cboSupplier.SelectedValue); rec.UnitID = VisibilitySetting.HandleUnits == 1 ? 0 : Convert.ToInt32(lkItemUnit.EditValue); pp.LoadByNewProgramIdAndItemId(Convert.ToInt32(rec.ItemID), previousprogid); if (pp.RowCount == 1) { rec.SubProgramID = Convert.ToInt32(lkPrograms.EditValue); pp.ProgramID = Convert.ToInt32(lkPrograms.EditValue); pp.ItemID = Convert.ToInt32(rec.ItemID); pp.Save(); } else if(pp.RowCount ==0) { rec.SubProgramID = Convert.ToInt32(lkPrograms.EditValue); pp.AddNew(); pp.ProgramID = rec.SubProgramID; pp.ItemID = Convert.ToInt32(rec.ItemID); pp.Save(); } rec.Cost = Convert.ToDouble(txtPrice.Text) / Convert.ToDouble(txtQtyPack.Text); rec.Save(); XtraMessageBox.Show("Transaction Succsfully Saved!", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information); this.Close(); } } } else { XtraMessageBox.Show(valid, "Validation", MessageBoxButtons.OK, MessageBoxIcon.Stop); } }