Ejemplo n.º 1
0
        private CGRMaster LoadImportedData(CMTMaster oMTMaster)
        {
            CGRMaster oGRMaster = new CGRMaster();

            oGRMaster.GRMstr_Branch = currentBranch.CompBrn_Branch;
            oGRMaster.GRMstr_By     = currentUser.User_OID;
            oGRMaster.GRMstr_RefBy  = oMTMaster.MTMstr_DOrder;
            oGRMaster.GRMstr_Type   = 0;
            oGRMaster.Creator       = currentUser.User_OID;
            oGRMaster.CreationDate  = DateTime.Now.Date;

            foreach (CMTDetails oMTDetails in oMTMaster.MTMstr_DetailsList)
            {
                CGRDetails oGRDetails = new CGRDetails();

                oGRDetails.GRDet_ItemOID = oMTDetails.MTDtls_ItemOID;
                oGRDetails.GRDet_QTY     = oMTDetails.MTDtls_IssQty;
                oGRDetails.GRDet_UOM     = oMTDetails.MTDtls_IssUOMOID;
                oGRDetails.GRDet_LocOID  = oMTDetails.MTDtls_DestLocOID;
                oGRDetails.GRDet_InvType = oMTDetails.MTDtls_DesInvtyp;

                oGRMaster.GRMstr_DetailsList.Add(oGRDetails);
            }

            return(oGRMaster);
        }
Ejemplo n.º 2
0
            private CGRDetails GetResultSetToGRDetails(DataRow dr)
            {
                CGRDetails oGRDetails = new CGRDetails();

                oGRDetails.GRDet_OID       = dr["GRDet_OID"].ToString();
                oGRDetails.GRDet_MStrOID   = dr["GRDet_MStrOID"].ToString();
                oGRDetails.GRDet_ItemOID   = dr["GRDet_ItemOID"].ToString();
                oGRDetails.GRDet_QTY       = float.Parse(dr["GRDet_QTY"].ToString());
                oGRDetails.GRDet_UOM       = dr["GRDet_UOM"].ToString();
                oGRDetails.GRDet_BranchOID = dr["GRDet_BranchOID"].ToString();
                oGRDetails.GRDet_LocOID    = dr["GRDet_LocOID"].ToString();
                oGRDetails.GRDet_InvType   = int.Parse(dr["GRDet_InvType"].ToString());
                oGRDetails.GRDet_Currency  = dr["GRDet_Currency"].ToString();
                oGRDetails.GRDet_Price     = float.Parse(dr["GRDet_Price"].ToString());
                oGRDetails.GRDet_Amount    = float.Parse(dr["GRDet_Amount"].ToString());

                return(oGRDetails);
            }
Ejemplo n.º 3
0
 private void btnImport_Click(object sender, EventArgs e)
 {
     try
     {
         progressBarImport.Value = 0;
         Cursor = Cursors.WaitCursor;
         string        selectGRFromHomeMaster = "select *from t_GRMstr where GRMatr_IsImported=0";
         SqlConnection oConnectionForHomeDB   = new CConManager().GetConnectionForRemote();
         DataTable     dtHome          = new DataTable();
         SqlCommand    oCommandForHome = new SqlCommand(selectGRFromHomeMaster, oConnectionForHomeDB);
         oCommandForHome.CommandType = CommandType.Text;
         SqlDataAdapter oSqlAdapter = new SqlDataAdapter(oCommandForHome);
         oSqlAdapter.Fill(dtHome);
         List <CGRMaster> oGRMasterList = new List <CGRMaster>();
         progressBarImport.Value = 70;
         if (dtHome.Rows.Count > 0)
         {
             progressBarImport.Value = 70;
             foreach (DataRow dr in dtHome.Rows)
             {
                 CGRMaster oGRMaster = new CGRMaster();
                 oGRMaster.GRMstr_OID        = "";
                 oGRMaster.GRMstr_Branch     = currentBranch.CompBrn_Code;
                 oGRMaster.GRMstr_Code       = GetGRmstrCode();
                 oGRMaster.GRMstr_Type       = int.Parse(dr["GRMstr_Type"].ToString());
                 oGRMaster.GRMstr_Date       = DateTime.Parse(dr["GRMstr_Date"].ToString());
                 oGRMaster.GRMstr_By         = dr["GRMstr_By"].ToString();
                 oGRMaster.Remarks           = dr["GRMstr_Remarks"].ToString();
                 oGRMaster.GRMstr_RefBy      = dr["GRMstr_RefBy"].ToString();
                 oGRMaster.Creator           = dr["GRMstr_Creator"].ToString();
                 oGRMaster.CreationDate      = DateTime.Parse(dr["GRMstr_CreationDate"].ToString());
                 oGRMaster.UpdateBy          = dr["GRMstr_UpdateBy"].ToString();
                 oGRMaster.UpdateDate        = DateTime.Parse(dr["GRMstr_UpdateDate"].ToString());
                 oGRMaster.IsActive          = "Y";
                 oGRMaster.GRMstr_IsImported = 1;
                 string        selectGRForHomeDetail      = "select *from t_GRDet where GRDet_MStrOID='" + dr["GRMstr_OID"].ToString() + "'";
                 SqlConnection oConnectionForHomeDBDetail = new CConManager().GetConnectionForRemote();
                 DataTable     dtHomedetail = new DataTable();
                 SqlCommand    oCommand     = new SqlCommand(selectGRForHomeDetail, oConnectionForHomeDBDetail);
                 oCommand.CommandType = CommandType.Text;
                 SqlDataAdapter oDataAdapter = new SqlDataAdapter(oCommand);
                 oDataAdapter.Fill(dtHomedetail);
                 //List<CGRDetails> oGRDetailList = new List<CGRDetails>();
                 if (dtHomedetail.Rows.Count > 0)
                 {
                     foreach (DataRow drDetail in dtHomedetail.Rows)
                     {
                         CGRDetails oGRDetails = new CGRDetails();
                         oGRDetails.GRDet_Branch    = currentBranch.CompBrn_Code;
                         oGRDetails.GRDet_ItemOID   = drDetail["GRDet_ItemOID"].ToString();
                         oGRDetails.GRDet_QTY       = float.Parse(drDetail["GRDet_QTY"].ToString());
                         oGRDetails.GRDet_UOM       = drDetail["GRDet_UOM"].ToString();
                         oGRDetails.GRDet_BranchOID = currentBranch.CompBrn_OId;
                         oGRDetails.GRDet_LocOID    = drDetail["GRDet_LocOID"].ToString();
                         oGRDetails.GRDet_InvType   = int.Parse(drDetail["GRDet_InvType"].ToString());
                         oGRDetails.GRDet_Price     = float.Parse(drDetail["GRDet_Price"].ToString());
                         oGRDetails.GRDet_Currency  = drDetail["GRDet_Currency"].ToString();
                         oGRDetails.GRDet_Amount    = float.Parse(drDetail["GRDet_Amount"].ToString());
                         //oGRDetailList.Add(oGRDetails);
                         oGRMaster.GRMstr_DetailsList.Add(oGRDetails);
                     }
                 }
                 //oGRMaster.GRMstr_DetailsList = oGRDetailList;
                 oGRMasterList.Add(oGRMaster);
             }
             if (oGRMasterList.Count > 0)
             {
                 foreach (CGRMaster oGRMaster in oGRMasterList)
                 {
                     progressBarImport.Value = 50;
                     CResult oResult = new CResult();
                     CGRBO   oGRBO   = new CGRBO();
                     if (oGRMaster != null)
                     {
                         oResult = oGRBO.Create(oGRMaster);
                     }
                     if (oResult.IsSuccess)
                     {
                         progressBarImport.Value = 100;
                         this.Cursor             = Cursors.Default;
                         oResult = oGRBO.UpdateHomeGRTable();
                     }
                     progressBarImport.Value = 100;
                     MessageBox.Show("Goods are successfully Imported", "ETLPOS", MessageBoxButtons.OK, MessageBoxIcon.Information);
                 }
             }
         }
         else if (dtHome.Rows.Count <= 0)
         {
             DialogResult oDR = MessageBox.Show("You Have No Goods For Import", "ETLPOS", MessageBoxButtons.OKCancel, MessageBoxIcon.Information);
             if (oDR.ToString() == "OK")
             {
                 this.Cursor             = Cursors.Default;
                 progressBarImport.Value = 0;
             }
         }
     }
     catch
     {
         MessageBox.Show("You Have No Goods For Import", "ETLPOS", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
Ejemplo n.º 4
0
        private CGRMaster GetToBSavedDataExportBranch()
        {
            oGRFinalQtyDic.Clear();

            CGRMaster oGRMaster = new CGRMaster();

            oGRMaster.GRMstr_OID    = txtSelectedGROID.Text.Trim();
            oGRMaster.GRMstr_Branch = currentBranch.CompBrn_Code;//cmbBranch.SelectedItem.ToString();
            oGRMaster.GRMstr_Code   = txtGRNo.Text.Trim();
            oGRMaster.GRMstr_Type   = Convert.ToInt32(Enum.Parse(typeof(EGRType), ddlType.SelectedItem.ToString()));
            oGRMaster.GRMstr_Date   = dtpGRDate.Value.Date;
            oGRMaster.GRMstr_By     = txtRecievedBy.Text.Trim();
            oGRMaster.Remarks       = txtRemarks.Text.Trim();

            if (currentBranch.CompBrn_OId == "CompBrnXBRN01 0000000001")
            {
                oGRMaster.GRMstr_IsImported = 0;
            }
            else if (currentBranch.CompBrn_OId != "CompBrnXBRN01 0000000001")
            {
                oGRMaster.GRMstr_IsImported = 1;
            }
            // oGRMaster.GRMstr_VendorID = ddlSupplier.SelectedValue.ToString();
            oGRMaster.GRMstr_RefBy = txtRefNo.Text.Trim();


            oGRMaster.Creator      = currentUser.User_OID;
            oGRMaster.CreationDate = DateTime.Now.Date;
            oGRMaster.UpdateBy     = currentUser.User_OID;
            oGRMaster.UpdateDate   = DateTime.Now.Date;
            oGRMaster.IsActive     = "Y";
            oGRMaster.Remarks      = "";


            for (int i = 0; i < dgItemList.Rows.Count - 1; i++)
            {
                if (ValidateListItem(dgItemList.Rows[i]))
                {
                    CGRDetails     oGRDetails     = new CGRDetails();
                    CCompanyBranch oCompanyBranch = (CCompanyBranch)cmbBranch.SelectedItem;
                    oGRDetails.GR_Date      = DateTime.Now.Date;
                    oGRDetails.GRDet_Branch = oCompanyBranch.CompBrn_Code;

                    oGRDetails.GRDet_ItemOID = ((DataGridViewComboBoxCell)dgItemList.Rows[i].Cells["colItemName"]).Value.ToString();
                    if (dgItemList.Rows[i].Cells["colIssueqty"].Value != null)
                    {
                        oGRDetails.GRDet_QTY = float.Parse(((DataGridViewTextBoxCell)dgItemList.Rows[i].Cells["colIssueqty"]).Value.ToString());
                    }

                    if (dgItemList.Rows[i].Cells["colIssueUOM"].Value != null)
                    {
                        oGRDetails.GRDet_UOM = ((DataGridViewComboBoxCell)dgItemList.Rows[i].Cells["colIssueUOM"]).Value.ToString();
                    }

                    oGRDetails.GRDet_BranchOID = currentBranch.CompBrn_OId;

                    if (dgItemList.Rows[i].Cells["colSourceLoc"].Value != null)
                    {
                        oGRDetails.GRDet_LocOID = ((DataGridViewComboBoxCell)dgItemList.Rows[i].Cells["colSourceLoc"]).Value.ToString();
                    }

                    if (dgItemList.Rows[i].Cells["colSrcInvType"].Value != null)
                    {
                        oGRDetails.GRDet_InvType = Convert.ToInt32(Enum.Parse(typeof(EInvType), ((DataGridViewComboBoxCell)dgItemList.Rows[i].Cells["colSrcInvType"]).Value.ToString()));
                    }

                    if (dgItemList.Rows[i].Cells["colPrice"].Value != null)
                    {
                        oGRDetails.GRDet_Price = float.Parse(((DataGridViewTextBoxCell)dgItemList.Rows[i].Cells["colPrice"]).Value.ToString());
                    }
                    if (dgItemList.Rows[i].Cells["colCurrency"].Value != null)
                    {
                        oGRDetails.GRDet_Currency = ((DataGridViewComboBoxCell)dgItemList.Rows[i].Cells["colCurrency"]).Value.ToString();
                    }
                    if (dgItemList.Rows[i].Cells["colAmount"].Value != null)
                    {
                        oGRDetails.GRDet_Amount = float.Parse(((DataGridViewTextBoxCell)dgItemList.Rows[i].Cells["colAmount"]).Value.ToString());
                    }

                    oGRMaster.GRMstr_DetailsList.Add(oGRDetails);


                    CGRDetails oInvGRDetails = new CGRDetails();

                    oInvGRDetails.GRDet_Branch    = oGRDetails.GRDet_Branch;
                    oInvGRDetails.GRDet_BranchOID = oGRDetails.GRDet_BranchOID;
                    oInvGRDetails.GRDet_ItemOID   = oGRDetails.GRDet_ItemOID;
                    oInvGRDetails.GRDet_LocOID    = oGRDetails.GRDet_LocOID;
                    oInvGRDetails.GRDet_InvType   = oGRDetails.GRDet_InvType;
                    if (dgItemList.Rows[i].Cells["colInvtQty"].Value != null)
                    {
                        oInvGRDetails.GRDet_QTY = float.Parse(((DataGridViewTextBoxCell)dgItemList.Rows[i].Cells["colInvtQty"]).Value.ToString());
                    }
                    else
                    {
                        oInvGRDetails.GRDet_QTY = 0.00f;
                    }
                    oGRFinalQtyDic.Add(oInvGRDetails.GRDet_ItemOID, oInvGRDetails);
                }
                else
                {
                    return(null);
                }
            }

            foreach (string obj in oGRExistingQtyDic.Keys)
            {
                if (!oGRFinalQtyDic.ContainsKey(obj))
                {
                    CGRDetails objDetls = new CGRDetails();
                    objDetls.GRDet_Branch    = oGRExistingQtyDic[obj].GRDet_Branch;
                    objDetls.GRDet_BranchOID = oGRExistingQtyDic[obj].GRDet_BranchOID;
                    objDetls.GRDet_InvType   = oGRExistingQtyDic[obj].GRDet_InvType;
                    objDetls.GRDet_ItemOID   = oGRExistingQtyDic[obj].GRDet_ItemOID;
                    objDetls.GRDet_LocOID    = oGRExistingQtyDic[obj].GRDet_LocOID;
                    objDetls.GRDet_QTY       = oGRExistingQtyDic[obj].GRDet_QTY * -1;

                    oGRFinalQtyDic.Add(obj, objDetls);
                }
            }

            return(oGRMaster);
        }