Example #1
0
        private void FindExisitingTransfer(string ReqNo)
        {
            try
            {
                if (T_damageDL.ExistingT_damage(ReqNo.Trim()))
                {
                    formMode = 3;
                    //clear datagrid
                    dtx.Clear();
                    dataGridView1.Refresh();

                    //clear error fields
                    errorProvider1.Clear();

                    t_damage cat = new t_damage();
                    cat.no = ReqNo.Trim();
                    T_damageDL dl = new T_damageDL();
                    cat = dl.Selectt_damage(cat);

                    //set the process message and mode to edit mode
                    if (cat.isProcessed == false)
                    {
                        lbl_processes.Visible = false;
                        performButtons(xEnums.PerformanceType.Edit);
                    }
                    else
                    {
                        lbl_processes.Visible = true;
                    }

                    //load and disable the data fields
                    txt_sourceLocId.Text = cat.locationId.Trim();
                    txt_remarks.Text     = cat.remarks;
                    textareaFunctions(false);

                    t_damage_detail req = new t_damage_detail();
                    req.damageNo = ReqNo.Trim();
                    T_damage_detailDL      tdl      = new T_damage_detailDL();
                    List <t_damage_detail> requests = new List <t_damage_detail>();
                    requests = tdl.SelectT_damage_detailMulti(req);

                    foreach (t_damage_detail det in requests)
                    {
                        commonFunctions.AddRow(dtx, det.itemCode, findExisting.FindExisitingStock(det.itemCode).Trim(), det.costPrice.ToString(), det.sellingPrice.ToString(), det.quantity.ToString(), det.amount.ToString());
                    }

                    txt_net.Text         = commonFunctions.GetGrossAmount(dataGridView1).ToString();
                    txt_grossAmount.Text = commonFunctions.GetGrossAmount(dataGridView1).ToString();
                    txt_noOfPeaces.Text  = commonFunctions.GetNoofPices(dataGridView1).ToString();
                    txt_noOfItems.Text   = commonFunctions.GetNoofItems(dataGridView1).ToString();
                }
                else
                {
                    if (formMode != 1)
                    {
                        errorProvider1.SetError(txt_no, "Adjutmnt Number you have entered does not exists in the system.");
                        commonFunctions.SetMDIStatusMessage("Adjutmnt Number you have entered does not exists in the system.", 1);
                    }
                }
            }
            catch (Exception ex)
            {
                LogFile.WriteErrorLog(System.Reflection.MethodBase.GetCurrentMethod().Name, this.Name, ex.Message.ToString(), "Exception");
                commonFunctions.SetMDIStatusMessage("Genaral Error on loading data", 1);
            }
        }
Example #2
0
        private void performButtons(xEnums.PerformanceType xenum)
        {
            try
            {
                switch (xenum)
                {
                case xEnums.PerformanceType.View:
                    if (ActiveControl.Name.Trim() == txt_no.Name.Trim())
                    {
                        int      length         = Convert.ToInt32(ConfigurationManager.AppSettings["POFieldLength"]);
                        string[] strSearchField = new string[length];

                        string strSQL = ConfigurationManager.AppSettings["POSQL"].ToString();

                        for (int i = 0; i < length; i++)
                        {
                            string m;
                            m = i.ToString();
                            strSearchField[i] = ConfigurationManager.AppSettings["POField" + m + ""].ToString();
                        }

                        frmU_Search find = new frmU_Search(strSQL, strSearchField, this);
                        find.ShowDialog(this);
                    }

                    break;

                case xEnums.PerformanceType.New:
                    FunctionButtonStatus(xEnums.PerformanceType.New);
                    formMode    = 1;
                    txt_no.Text = commonFunctions.GetSerial(formID.Trim());
                    txt_no.Focus();

                    txt_sourceLocId.Text     = commonFunctions.GlobalLocation;
                    txt_locationId_name.Text = findExisting.FindExisitingLoca(txt_sourceLocId.Text.Trim());

                    errorProvider1.Clear();

                    lbl_processes.Visible = false;
                    break;

                case xEnums.PerformanceType.Edit:
                    FunctionButtonStatus(xEnums.PerformanceType.Edit);
                    formMode = 3;
                    //txt_VehicleID.Enabled = false;
                    //txt_VehicleNo.Focus();
                    errorProvider1.Clear();
                    break;

                case xEnums.PerformanceType.Save:
                    errorProvider1.Clear();
                    if (formMode == 1)
                    {
                        if (!M_LocaDL.ExistingM_Loca(txt_sourceLocId.Text.Trim()))
                        {
                            errorProvider1.SetError(txt_sourceLocId, "Location does not exists on the system ");
                            commonFunctions.SetMDIStatusMessage("Location does not exists on the system", 1);
                            return;
                        }

                        if (commonFunctions.GetNoofItems(dataGridView1) <= 0)
                        {
                            errorProvider1.SetError(dataGridView1, "Please enter some items to the details grid");
                            commonFunctions.SetMDIStatusMessage("Please enter some items to the details grid", 1);
                            return;
                        }



                        if (UserDefineMessages.ShowMsg("", UserDefineMessages.Msg_PerfmBtn_Save, commonFunctions.Softwarename.Trim()) == System.Windows.Forms.DialogResult.Yes)
                        {
                            try
                            {
                                using (System.Transactions.TransactionScope transaction = new System.Transactions.TransactionScope())
                                {
                                    //u_DBConnection.BeginTrans();
                                    //save header data
                                    t_damage objt_damage = new t_damage();
                                    objt_damage.no          = txt_no.Text.Trim();
                                    objt_damage.date        = dte_date.Value;
                                    objt_damage.refNo       = txt_refNo.Text.Trim();
                                    objt_damage.refDate     = dte_refe.Value;
                                    objt_damage.remarks     = txt_remarks.Text.Trim();
                                    objt_damage.locationId  = commonFunctions.GlobalLocation;
                                    objt_damage.noOfItems   = commonFunctions.ToDecimal(txt_noOfItems.Text.Trim());
                                    objt_damage.noOfPeaces  = commonFunctions.ToDecimal(txt_noOfPeaces.Text.Trim());
                                    objt_damage.grossAmount = commonFunctions.ToDecimal(txt_grossAmount.Text.Trim());
                                    objt_damage.isSaved     = true;
                                    objt_damage.isProcessed = false;
                                    objt_damage.processDate = DateTime.Now;
                                    objt_damage.processUser = "";
                                    objt_damage.GLUpdate    = false;
                                    objt_damage.triggerVal  = 1;
                                    T_damageDL bal = new T_damageDL();
                                    bal.Savet_damageSP(objt_damage, 1);

                                    //save details
                                    foreach (DataGridViewRow drow in dataGridView1.Rows)
                                    {
                                        if (drow.Cells["Product Code"].Value.ToString().Trim() != null)
                                        {
                                            //have to implement the logic. this is only saving the data to the system
                                            t_damage_detail objt_damage_detail = new t_damage_detail();
                                            objt_damage_detail.damageNo     = txt_no.Text.Trim();
                                            objt_damage_detail.locationId   = commonFunctions.GlobalLocation;
                                            objt_damage_detail.damageDate   = dte_date.Value;
                                            objt_damage_detail.itemCode     = drow.Cells["Product Code"].Value.ToString();
                                            objt_damage_detail.description  = findExisting.FindExisitingProduct(drow.Cells["Product Code"].Value.ToString());
                                            objt_damage_detail.quantity     = commonFunctions.ToDecimal(drow.Cells["Quntity"].Value.ToString());
                                            objt_damage_detail.uom          = "PCS"; //txt_uom.Text.Trim();
                                            objt_damage_detail.costPrice    = commonFunctions.ToDecimal(drow.Cells["Cost Price"].Value.ToString());
                                            objt_damage_detail.sellingPrice = commonFunctions.ToDecimal(drow.Cells["Selling Price"].Value.ToString());
                                            objt_damage_detail.amount       = commonFunctions.ToDecimal(drow.Cells["Amount"].Value.ToString());
                                            objt_damage_detail.triggerVal   = 1;
                                            T_damage_detailDL bal2 = new T_damage_detailDL();
                                            bal2.Savet_damage_detailSP(objt_damage_detail, 1);
                                        }
                                    }

                                    //increment the serial
                                    commonFunctions.IncrementSerial(formID);
                                    transaction.Complete();
                                }
                                //u_DBConnection.CommitTrans();
                                UserDefineMessages.ShowMsg("", UserDefineMessages.Msg_Save_Sucess, commonFunctions.Softwarename.Trim());
                            }
                            catch (Exception ex)
                            {
                                // u_DBConnection.RollbackTrans();
                                LogFile.WriteErrorLog(System.Reflection.MethodBase.GetCurrentMethod().Name, this.Name, ex.Message.ToString(), "Exception");
                                commonFunctions.SetMDIStatusMessage("Genaral Error on saving data", 1);
                            }

                            if (UserDefineMessages.ShowMsg("", UserDefineMessages.Msg_PerfmBtn_Process, commonFunctions.Softwarename.Trim()) == System.Windows.Forms.DialogResult.Yes)
                            {
                                UpdateStock();
                                t_damage objt_trnsferNote = new t_damage();
                                objt_trnsferNote.no = txt_no.Text.Trim();

                                T_damageDL balprocess = new T_damageDL();
                                objt_trnsferNote = balprocess.Selectt_damage(objt_trnsferNote);

                                objt_trnsferNote.isProcessed = true;
                                objt_trnsferNote.processDate = DateTime.Now;
                                objt_trnsferNote.processUser = commonFunctions.Loginuser;
                                balprocess.Savet_damageSP(objt_trnsferNote, 3);
                                UserDefineMessages.ShowMsg("", UserDefineMessages.Msg_Update_Sucess, commonFunctions.Softwarename.Trim());
                            }


                            //clear data in data grid
                            dtx.Rows.Clear();
                            dataGridView1.Refresh();
                            //clear text fields
                            textareaFunctions(true);

                            FunctionButtonStatus(xEnums.PerformanceType.Save);
                            //increment the serial
                            txt_no.Text = commonFunctions.GetSerial(formID.Trim());
                            //txt_supplierId.Focus();
                        }
                    }
                    else if (formMode == 3)
                    {
                        t_trnsferInNote cat = new t_trnsferInNote();
                        cat.transinNo = txt_no.Text.Trim();
                        T_trnsferInNoteDL dl = new T_trnsferInNoteDL();
                        cat = dl.Selectt_trnsferInNote(cat);
                        if (cat.isProcessed == false)
                        {
                            if (UserDefineMessages.ShowMsg("", UserDefineMessages.Msg_PerfmBtn_Process, commonFunctions.Softwarename.Trim()) == System.Windows.Forms.DialogResult.Yes)
                            {
                                UpdateStock();

                                t_damage objt_trnsferNote = new t_damage();
                                objt_trnsferNote.no = txt_no.Text.Trim();

                                T_damageDL balprocess = new T_damageDL();
                                objt_trnsferNote = balprocess.Selectt_damage(objt_trnsferNote);

                                objt_trnsferNote.isProcessed = true;
                                objt_trnsferNote.processDate = DateTime.Now;
                                objt_trnsferNote.processUser = commonFunctions.Loginuser;
                                balprocess.Savet_damageSP(objt_trnsferNote, 3);
                                UserDefineMessages.ShowMsg("", UserDefineMessages.Msg_Update_Sucess, commonFunctions.Softwarename.Trim());

                                //clear data in data grid
                                dtx.Rows.Clear();
                                dataGridView1.Refresh();
                                //clear text fields
                                textareaFunctions(true);
                                FunctionButtonStatus(xEnums.PerformanceType.Save);

                                txt_no.Text = commonFunctions.GetSerial(formID.Trim());
                                txt_code.Focus();
                            }
                        }
                        else
                        {
                            errorProvider1.SetError(txt_no, "Damage Number you have entered already processed.");
                            commonFunctions.SetMDIStatusMessage("Damage Number you have entered already processed.", 1);
                        }
                    }
                    break;

                case xEnums.PerformanceType.Cancel:
                    txt_no.Enabled = true;
                    FunctionButtonStatus(xEnums.PerformanceType.Default);
                    errorProvider1.Clear();
                    //clear text fields
                    textareaFunctions(true);
                    //clear Datagrid
                    dtx.Clear();
                    dataGridView1.Refresh();

                    //txt_supplierId.Text = "";
                    //txt_remarks.Text = "";

                    lbl_processes.Visible = false;

                    break;

                case xEnums.PerformanceType.Print:
                    UserDefineMessages.ShowMsg1("Print still in process", UserDefineMessages.Msg_Information);
                    break;
                }
            }
            catch (Exception ex)
            {
                LogFile.WriteErrorLog(System.Reflection.MethodBase.GetCurrentMethod().Name, this.Name, ex.Message.ToString(), "Exception");
                commonFunctions.SetMDIStatusMessage("Genaral Error on updating data", 1);
            }
        }