void GenerateFiles() { var da1 = new DataSet1TableAdapters.ITEMTRANSFERMAINTableAdapter(); var da2 = new DataSet1TableAdapters.ITEMTRANSFERDETAILTableAdapter(); var ds = new DataSet(); da1.FillByTranid(this.dataSet1.ITEMTRANSFERMAIN, purid); da2.FillByTranid(this.dataSet1.ITEMTRANSFERDETAIL, purid); string filename = Application.StartupPath + "\\ " + "HED" + purid.ToString() + ".xml"; string filename1 = Application.StartupPath + "\\" + "DET" + purid.ToString() + ".xml"; this.dataSet1.ITEMTRANSFERMAIN.WriteXml(filename); this.dataSet1.ITEMTRANSFERDETAIL.WriteXml(filename1); }
void DoSave() { c1TrueDBGrid1.UpdateData(); if (warehouse.EditValue == null) { XtraMessageBox.Show("Please select the from warehouse", "P.O.S", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } if (tostoreid.EditValue == null) { XtraMessageBox.Show("Please select the to store", "P.O.S", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } DateTime dtinv = DateTime.Parse(invdate.EditValue.ToString()); ArrayList Errorlist = new ArrayList(); if (!ishold) { if (warehouse.EditValue == null) { XtraMessageBox.Show("Please select the from warehouse", "P.O.S", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } if (tostoreid.EditValue == null) { XtraMessageBox.Show("Please select the to store", "P.O.S", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } foreach (DataRow d in this.dataSet1.ITEMTRANSFERDETAIL) { string t = ""; if (int.Parse(d["qty"].ToString()) > 0) { if (CheckStock(int.Parse(d["stockid"].ToString()), int.Parse(d["qty"].ToString()))) { t = "Sufficent stock not found for item :" + GetItemname((d["ITEMID"].ToString())); Errorlist.Add(t); } } if (decimal.Parse(d["sprice"].ToString()) == 0) { t = "Sales price not found for item : " + GetItemname((d["ITEMID"].ToString())); Errorlist.Add(t); } } } if (Errorlist.Count > 0) { var f = new Testing(Errorlist); f.ShowDialog(); return; } try { if (purid > 0) { issaved = true; var dr = this.dataSet1.ITEMTRANSFERMAIN.FindByTRANID(purid); if (dr != null) { dr.BeginEdit(); dr.FRMSTOREID = int.Parse(warehouse.EditValue.ToString()); dr.TOSTOREID =tostoreid.EditValue.ToString(); dr.HOLD = ishold; dr.EUSERID = COMMON.Utils.Userid; dr.EDATE = DateTime.Now; dr.TOTVALUE = decimal.Parse(netamt.EditValue.ToString()); dr.TOTITEMS = this.dataSet1.ITEMTRANSFERDETAIL.Rows.Count; dr.EndEdit(); this.iTEMTRANSFERDETAILTableAdapter.Update(dr); } } else { var InsertQ = new DataSet1TableAdapters.ITEMTRANSFERMAINTableAdapter(); purid = Convert.ToInt32(InsertQ.InsertQuery(int.Parse(warehouse.EditValue.ToString()), tostoreid.EditValue.ToString(), DateTime.Today.Date, COMMON.Utils.Userid, DateTime.Now, ishold, 0, null , decimal.Parse(netamt.EditValue.ToString()),this.dataSet1.ITEMTRANSFERDETAIL.Rows.Count).ToString()); } if (purid > 0) { textBox1.Text = purid.ToString(); issaved = true; foreach (DataRow d in this.dataSet1.ITEMTRANSFERDETAIL) { d["TRANID"] = purid; } iTEMTRANSFERDETAILTableAdapter.Update(this.dataSet1.ITEMTRANSFERDETAIL); if (ishold) { XtraMessageBox.Show("Invoice holded sucessfully", "P.O.S", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } else { UpdateStock(); GenerateFiles(); XtraMessageBox.Show("Invoice recorded sucessfully", "P.O.S", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } this.posMenu1.SaveButtonEnabled = false; } else { XtraMessageBox.Show("Error while saving please try again", "P.O.S", MessageBoxButtons.OK, MessageBoxIcon.Information); } } catch (Exception ex) { XtraMessageBox.Show(ex.ToString(), "P.O.S", MessageBoxButtons.OK, MessageBoxIcon.Information); } }