예제 #1
0
 public t_transferIn_detail Selectt_transferIn_detail(t_transferIn_detail objt_transferIn_detail)
 {
     try
     {
         strquery = @"select * from t_transferIn_detail where transinrNo = '" + objt_transferIn_detail.transinrNo + "'";
         DataRow drType = u_DBConnection.ReturnDataRow(strquery);
         if (drType != null)
         {
             objt_transferIn_detail.transinrNo       = drType["transinrNo"].ToString();
             objt_transferIn_detail.sourceLocId      = drType["sourceLocId"].ToString();
             objt_transferIn_detail.destinationLocId = drType["destinationLocId"].ToString();
             objt_transferIn_detail.transferDate     = DateTime.Parse(drType["transferDate"].ToString());
             objt_transferIn_detail.stockCode        = drType["stockCode"].ToString();
             objt_transferIn_detail.description      = drType["description"].ToString();
             objt_transferIn_detail.quantity         = decimal.Parse(drType["quantity"].ToString());
             objt_transferIn_detail.costPrice        = decimal.Parse(drType["costPrice"].ToString());
             objt_transferIn_detail.amount           = decimal.Parse(drType["amount"].ToString());
             objt_transferIn_detail.triggerVal       = int.Parse(drType["triggerVal"].ToString());
             return(objt_transferIn_detail);
         }
         return(null);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
예제 #2
0
        /// <summary>
        /// Saves a record to the t_transferIn_detail table.
        /// </summary>
        public Boolean Savet_transferIn_detailSP(t_transferIn_detail t_transferIn_detail, int formMode)
        {
            SqlCommand scom;
            bool       retvalue = false;

            try
            {
                scom             = new SqlCommand();
                scom.CommandType = CommandType.StoredProcedure;
                scom.CommandText = "T_transferIn_detailSave";

                scom.Parameters.Add("@transinrNo", SqlDbType.VarChar, 20).Value       = t_transferIn_detail.transinrNo;
                scom.Parameters.Add("@sourceLocId", SqlDbType.VarChar, 20).Value      = t_transferIn_detail.sourceLocId;
                scom.Parameters.Add("@destinationLocId", SqlDbType.VarChar, 20).Value = t_transferIn_detail.destinationLocId;
                scom.Parameters.Add("@transferDate", SqlDbType.DateTime, 8).Value     = t_transferIn_detail.transferDate;
                scom.Parameters.Add("@stockCode", SqlDbType.VarChar, 20).Value        = t_transferIn_detail.stockCode;
                scom.Parameters.Add("@description", SqlDbType.VarChar, 150).Value     = t_transferIn_detail.description;
                scom.Parameters.Add("@quantity", SqlDbType.Decimal, 9).Value          = t_transferIn_detail.quantity;
                scom.Parameters.Add("@costPrice", SqlDbType.Decimal, 9).Value         = t_transferIn_detail.costPrice;
                scom.Parameters.Add("@amount", SqlDbType.Decimal, 9).Value            = t_transferIn_detail.amount;
                scom.Parameters.Add("@triggerVal", SqlDbType.Int, 4).Value            = t_transferIn_detail.triggerVal;
                scom.Parameters.Add("@InsMode", SqlDbType.Int).Value  = formMode; // For insert
                scom.Parameters.Add("@RtnValue", SqlDbType.Int).Value = 0;

                u_DBConnection dbcon = new u_DBConnection();
                retvalue = dbcon.RunQuery(scom);
                return(retvalue);
            }
            catch (Exception ex)
            {
                throw (ex);
            }
        }
예제 #3
0
        public List <t_transferIn_detail> SelectT_transferIn_detailMulti(t_transferIn_detail objt_transferIn_detail2)
        {
            List <t_transferIn_detail> retval = new List <t_transferIn_detail>();

            try
            {
                strquery = @"select * from t_transferIn_detail where transinrNo = '" + objt_transferIn_detail2.transinrNo + "'";
                DataTable dtt_transferIn_detail = u_DBConnection.ReturnDataTable(strquery, CommandType.Text);
                foreach (DataRow drType in dtt_transferIn_detail.Rows)
                {
                    if (drType != null)
                    {
                        t_transferIn_detail objt_transferIn_detail = new t_transferIn_detail();
                        objt_transferIn_detail.transinrNo       = drType["transinrNo"].ToString();
                        objt_transferIn_detail.sourceLocId      = drType["sourceLocId"].ToString();
                        objt_transferIn_detail.destinationLocId = drType["destinationLocId"].ToString();
                        objt_transferIn_detail.transferDate     = DateTime.Parse(drType["transferDate"].ToString());
                        objt_transferIn_detail.stockCode        = drType["stockCode"].ToString();
                        objt_transferIn_detail.description      = drType["description"].ToString();
                        objt_transferIn_detail.quantity         = decimal.Parse(drType["quantity"].ToString());
                        objt_transferIn_detail.costPrice        = decimal.Parse(drType["costPrice"].ToString());
                        objt_transferIn_detail.amount           = decimal.Parse(drType["amount"].ToString());
                        objt_transferIn_detail.triggerVal       = int.Parse(drType["triggerVal"].ToString());
                        retval.Add(objt_transferIn_detail);
                    }
                }
                return(retval);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
예제 #4
0
        private void UpdateStock()
        {
            try
            {
                t_transferIn_detail trans = new t_transferIn_detail();
                trans.transinrNo = txt_no.Text.Trim();
                List <t_transferIn_detail> Transins = new List <t_transferIn_detail>();
                Transins = new T_transferIn_detailDL().SelectT_transferIn_detailMulti(trans);

                foreach (t_transferIn_detail det in Transins)
                {
                    //reduce stock from this location
                    T_StockDL.AddStock_Update(det.stockCode, commonFunctions.GlobalCompany, commonFunctions.GlobalLocation, det.quantity.Value);

                    //update stock on destination
                    if (T_StockDL.ExistingT_Stock_new(det.stockCode.Trim(), commonFunctions.GlobalCompany, txt_destinationLocId.Text.Trim()))
                    {
                        //modify is already has record
                        T_StockDL.ReduceStock_Update(det.stockCode, commonFunctions.GlobalCompany, txt_destinationLocId.Text.Trim(), det.quantity.Value);
                    }
                    else
                    {
                        //insert
                        T_Stock objt_Stock = new T_Stock();
                        objt_Stock.StockCode = det.stockCode;
                        objt_Stock.Compcode  = commonFunctions.GlobalCompany;
                        objt_Stock.Locacode  = commonFunctions.GlobalLocation;
                        objt_Stock           = new T_StockDL().Selectt_Stock_new(objt_Stock);
                        T_StockDL.AddStock_Insert(objt_Stock, commonFunctions.GlobalCompany, txt_destinationLocId.Text.Trim(), det.quantity.Value);
                    }
                }
            }
            catch (Exception ex)
            {
                commonFunctions.SetMDIStatusMessage("Genaral Error on updating data", 1);
                throw ex;
            }
        }
예제 #5
0
        private void FindExisitingTransfer(string ReqNo)
        {
            try{
                if (T_trnsferInNoteDL.ExistingT_trnsferInNote(ReqNo.Trim()))
                {
                    formMode = 3;
                    //clear datagrid
                    dtx.Clear();
                    dataGridView1.Refresh();

                    //clear error fields
                    errorProvider1.Clear();

                    t_trnsferInNote cat = new t_trnsferInNote();
                    cat.transinNo = ReqNo.Trim();
                    T_trnsferInNoteDL dl = new T_trnsferInNoteDL();
                    cat = dl.Selectt_trnsferInNote(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_destinationLocId.Text = cat.destinationLocId.Trim();
                    txt_sourceLocId.Text      = cat.sourceLocId.Trim();
                    //txt_supplierId.Text = cat.supplierId.Trim();
                    txt_remarks.Text = cat.remarks;
                    dte_date.Value   = cat.date;

                    textareaFunctions(false);

                    t_transferIn_detail req = new t_transferIn_detail();
                    req.transinrNo = ReqNo.Trim();
                    T_transferIn_detailDL      tdl      = new T_transferIn_detailDL();
                    List <t_transferIn_detail> requests = new List <t_transferIn_detail>();
                    requests = tdl.SelectT_transferIn_detailMulti(req);

                    foreach (t_transferIn_detail det in requests)
                    {
                        commonFunctions.AddRow(dtx, det.stockCode, findExisting.FindExisitingStock(det.stockCode).Trim(), det.costPrice.ToString(), det.costPrice.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, "Transfer In Number you have entered does not exists in the system.");
                    }
                }
            }
            catch (Exception ex)
            {
                LogFile.WriteErrorLog(System.Reflection.MethodBase.GetCurrentMethod().Name, this.Name, ex.Message.ToString(), "Exception");
                commonFunctions.SetMDIStatusMessage("Genaral Error", 1);
            }
        }
예제 #6
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 (txt_sourceLocId.Text.Trim().ToUpper() == txt_destinationLocId.Text.Trim().ToUpper())
                        {
                            errorProvider1.SetError(txt_destinationLocId, "Destination location cannot same as login location");
                            return;
                        }


                        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 (!M_LocaDL.ExistingM_Loca(txt_destinationLocId.Text.Trim()))
                        {
                            errorProvider1.SetError(txt_destinationLocId, "Destination Location does not exists on the system ");
                            commonFunctions.SetMDIStatusMessage("Destination 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_trnsferInNote objt_trnsferInNote = new t_trnsferInNote();
                                    objt_trnsferInNote.transinNo        = txt_no.Text.Trim();
                                    objt_trnsferInNote.sourceLocId      = commonFunctions.GlobalLocation;
                                    objt_trnsferInNote.date             = dte_date.Value;
                                    objt_trnsferInNote.refNo            = txt_refNo.Text.Trim();
                                    objt_trnsferInNote.remarks          = txt_remarks.Text.Trim();
                                    objt_trnsferInNote.destinationLocId = txt_destinationLocId.Text.Trim();
                                    objt_trnsferInNote.purchaseReqNo    = txt_purchaseReqNo.Text.Trim();
                                    objt_trnsferInNote.noOfItems        = commonFunctions.ToDecimal(txt_noOfItems.Text.Trim());
                                    objt_trnsferInNote.noOfPeaces       = commonFunctions.ToDecimal(txt_noOfPeaces.Text.Trim());
                                    objt_trnsferInNote.grossAmount      = commonFunctions.ToDecimal(txt_grossAmount.Text.Trim());
                                    objt_trnsferInNote.isProcessed      = false;
                                    objt_trnsferInNote.processDate      = DateTime.Now;
                                    objt_trnsferInNote.processUser      = "";
                                    objt_trnsferInNote.GLUpdate         = false;
                                    objt_trnsferInNote.triggerVal       = 1;
                                    T_trnsferInNoteDL bal = new T_trnsferInNoteDL();
                                    bal.Savet_trnsferInNoteSP(objt_trnsferInNote, 1);


                                    //save details
                                    foreach (DataGridViewRow drow in dataGridView1.Rows)
                                    {
                                        if (drow.Cells["Product Code"].Value.ToString().Trim() != null)
                                        {
                                            t_transferIn_detail objt_transferIn_detail = new t_transferIn_detail();
                                            objt_transferIn_detail.transinrNo       = txt_no.Text.Trim();
                                            objt_transferIn_detail.sourceLocId      = commonFunctions.GlobalLocation;
                                            objt_transferIn_detail.destinationLocId = txt_destinationLocId.Text.Trim();
                                            objt_transferIn_detail.transferDate     = dte_date.Value;
                                            objt_transferIn_detail.stockCode        = drow.Cells["Product Code"].Value.ToString();
                                            objt_transferIn_detail.description      = drow.Cells["Product Name"].Value.ToString();
                                            objt_transferIn_detail.quantity         = commonFunctions.ToDecimal(drow.Cells["Quntity"].Value.ToString());
                                            objt_transferIn_detail.costPrice        = commonFunctions.ToDecimal(drow.Cells["Cost Price"].Value.ToString());
                                            objt_transferIn_detail.amount           = commonFunctions.ToDecimal(drow.Cells["Amount"].Value.ToString());
                                            objt_transferIn_detail.triggerVal       = 1;
                                            T_transferIn_detailDL bal2 = new T_transferIn_detailDL();
                                            bal2.Savet_transferIn_detailSP(objt_transferIn_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("Save Transactions", "Transfer In", ex.Message);
                                LogFile.WriteErrorLog("Save Transactions", "Transfer Out", ex.Message);
                                commonFunctions.SetMDIStatusMessage("Transfer Number you have entered already processed", 1);
                            }

                            if (UserDefineMessages.ShowMsg("", UserDefineMessages.Msg_PerfmBtn_Process, commonFunctions.Softwarename.Trim()) == System.Windows.Forms.DialogResult.Yes)
                            {
                                UpdateStock();

                                t_trnsferInNote objt_trnsferNote = new t_trnsferInNote();
                                objt_trnsferNote.transinNo = txt_no.Text.Trim();

                                T_trnsferInNoteDL balprocess = new T_trnsferInNoteDL();
                                objt_trnsferNote = balprocess.Selectt_trnsferInNote(objt_trnsferNote);

                                objt_trnsferNote.isProcessed = true;
                                objt_trnsferNote.processDate = DateTime.Now;
                                objt_trnsferNote.processUser = commonFunctions.Loginuser;
                                balprocess.Savet_trnsferInNoteSP(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_trnsferInNote objt_trnsferNote = new t_trnsferInNote();
                                objt_trnsferNote.transinNo = txt_no.Text.Trim();

                                T_trnsferInNoteDL balprocess = new T_trnsferInNoteDL();
                                objt_trnsferNote = balprocess.Selectt_trnsferInNote(objt_trnsferNote);

                                objt_trnsferNote.isProcessed = true;
                                objt_trnsferNote.processDate = DateTime.Now;
                                objt_trnsferNote.processUser = commonFunctions.Loginuser;
                                balprocess.Savet_trnsferInNoteSP(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_refNo.Focus();
                            }
                        }
                        else
                        {
                            errorProvider1.SetError(txt_no, "Transfer IN Number you have entered already processed.");
                        }
                    }
                    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 loading data", 1);
            }
        }