예제 #1
0
 private void BtnExit_Click(object sender, EventArgs e)
 {
     ClsGlobal.ConfirmFormCloseing(this);
 }
예제 #2
0
        private void BtnSave_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(TxtDescription.Text.Trim()))
            {
                MessageBox.Show("Account SubGroup Description is Required.", "Mr Solution", MessageBoxButtons.OK, MessageBoxIcon.Information);
                TxtDescription.Focus();
                return;
            }
            if (string.IsNullOrEmpty(TxtShortName.Text.Trim()))
            {
                MessageBox.Show("Account SubGroup ShortName is Required.", "Mr Solution", MessageBoxButtons.OK, MessageBoxIcon.Information);
                TxtShortName.Focus();
                return;
            }

            _objAccountSubGroup.Model.Tag             = _Tag;
            _objAccountSubGroup.Model.AccountSubGrpId = Convert.ToInt32(TxtDescription.Tag.ToString());
            if ((_Tag == "EDIT" || _Tag == "DELETE") && Convert.ToInt32(TxtDescription.Tag.ToString()) == 0)
            {
                ClearFld();
                TxtDescription.Focus();
                return;
            }
            _objAccountSubGroup.Model.AccountSubGrpDesc      = TxtDescription.Text;
            _objAccountSubGroup.Model.AccountSubGrpShortName = TxtShortName.Text;
            _objAccountSubGroup.Model.AccountGrpId           = Convert.ToInt32(TxtAccountGroup.Tag.ToString());
            _objAccountSubGroup.Model.EnterBy = ClsGlobal.LoginUserCode;
            _objAccountSubGroup.Model.Status  = CbActive.Checked == true ? true : false;
            _objAccountSubGroup.Model.Gadget  = "Desktop";
            if (_Tag == "NEW")
            {
                if (ClsGlobal.ConfirmSave == 1)
                {
                    DialogResult dialogResult = MessageBox.Show("Are you sure want to Save New Record..??", "Close Form", MessageBoxButtons.YesNo, MessageBoxIcon.Error);
                    if (dialogResult == DialogResult.Yes)
                    {
                        result = _objAccountSubGroup.SaveAccountSubGroup();
                    }
                    else
                    {
                        return;
                    }
                }
                else
                {
                    result = _objAccountSubGroup.SaveAccountSubGroup();
                }
            }
            else
            {
                result = _objAccountSubGroup.SaveAccountSubGroup();
            }

            if (!string.IsNullOrEmpty(result))
            {
                if (_IsNew == 'Y')
                {
                    _NewAccountSubGroup = TxtDescription.Text.Trim();
                    _AccountSubGrpId    = Convert.ToInt32(result);
                    Close();
                }
                else
                {
                    NavMenuDataList = _objAccountSubGroup.GetDataAccountSubGroup(0);
                    ClsGlobal.SaveMessage(_Tag);
                    ClearFld();
                }
            }
            else
            {
                MessageBox.Show("Account sub group already in used.", "Mr Solution", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
예제 #3
0
        public string SaveProduct()
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("BEGIN TRANSACTION \n");
            strSql.Append("BEGIN TRY \n");
            if (Model.Tag == "NEW")
            {
                strSql.Append("declare @ProductId int=(select ISNULL((Select Top 1 max(cast(productId as int))  from ERP.Product),0)+1) \n");
                strSql.Append("insert into ERP.product(ProductId, ProductDesc, ProductShortName, ProductPrintingName, GenericName, ProductAlias,ProductDescription, ProductCategory, ProductType, \n");
                strSql.Append("ValuationTech, ProductGrpId, PGrpId1, PGrpId2, ProductSubGrpId, IsBatchwise, IsSerialWise, IsSizewise, IsExpiryDate, \n");
                strSql.Append("IsManufacturingDate, SerialNo, PartsNo, ProductUnitId, QtyConv, ProductAltUnitId, AltConv, BuyRate, SalesRate, Margin1, TradeRate,\n");
                strSql.Append("Margin2, MRP, MRRate, MaxStock, MinStock, ReorderLevel, ReorderQty, PercentDisc, MinQty, MinDisc, MaxQty, MaxDisc,\n");
                strSql.Append("IsTaxable, TaxRate, PurchaseLedgerId, PurchaseReturnLedgerId, SalesLedgerId, SalesReturnLedgerId, PLOpeningLedgerId, \n");
                strSql.Append("PLClosingLedgerId, BSClosingLedgerId, DepreciationType, DepreciationLedgerId, DepreciationRate, PImage, DepartmentId, \n");
                strSql.Append("DepartmentId1, DepartmentId2, DepartmentId3, EnterBy, EnterDate, Status, BarCodeNo2, BarCodeNo1,Gadget,ProductModel)\n");
                strSql.Append("select @ProductId,N'" + Model.ProductDesc.Trim().Replace("'", "''") + "',N'" + Model.ProductShortName.Trim().Replace("'", "''") + "'," + ((Model.ProductPrintingName == "") ? "null" : "N'" + Model.ProductPrintingName.Trim().Replace("'", "''") + "'") + ",\n");
                strSql.Append("" + ((Model.GenericName == "") ? "null" : "N'" + Model.GenericName.Trim().Replace("'", "''") + "'") + "," + ((Model.ProductAlias == "") ? "null" : "N'" + Model.ProductAlias.Trim().Replace("'", "''") + "'") + "," + ((Model.ProductDescription == "") ? "null" : "N'" + Model.ProductDescription.Trim().Replace("'", "''") + "'") + ",N'" + Model.ProductCategory.Trim().Replace("'", "''") + "',N'" + Model.ProductType.Trim().Replace("'", "''") + "',\n");
                strSql.Append("N'" + Model.ValuationTech.Trim().Replace("'", "''") + "', " + ((Model.ProductGrpId == 0) ? "null" : "'" + Model.ProductGrpId + "'") + "," + ((Model.PGrpId1 == 0) ? "null" : "'" + Model.PGrpId1 + "'") + "," + ((Model.PGrpId2 == 0) ? "null" : "'" + Model.PGrpId2 + "'") + "," + ((Model.ProductSubGrpId == 0) ? "null" : "'" + Model.ProductSubGrpId + "'") + ",\n");
                strSql.Append("'" + Model.IsBatchwise + "','" + Model.IsSerialWise + "','" + Model.IsSizewise + "','" + Model.IsExpiryDate + "','" + Model.IsManufacturingDate + "',\n");
                strSql.Append("" + ((Model.SerialNo == "") ? "null" : "N'" + Model.SerialNo.Trim().Replace("'", "''") + "'") + "," + ((Model.PartsNo == "") ? "null" : "N'" + Model.PartsNo.Trim().Replace("'", "''") + "'") + "," + ((Model.ProductUnitId == 0) ? "null" : "'" + Model.ProductUnitId + "'") + ",'" + ClsGlobal.Val(Model.QtyConv.ToString()) + "'," + ((Model.ProductAltUnitId == 0) ? "null" : "'" + Model.ProductAltUnitId + "'") + ",\n");
                strSql.Append("'" + Model.AltConv + "','" + ClsGlobal.Val(Model.BuyRate.ToString()) + "','" + ClsGlobal.Val(Model.SalesRate.ToString()) + "','" + ClsGlobal.Val(Model.Margin1.ToString()) + "','" + ClsGlobal.Val(Model.TradeRate.ToString()) + "',\n");
                strSql.Append("'" + ClsGlobal.Val(Model.Margin2.ToString()) + "','" + ClsGlobal.Val(Model.MRP.ToString()) + "','" + ClsGlobal.Val(Model.MRRate.ToString()) + "','" + ClsGlobal.Val(Model.MaxStock.ToString()) + "','" + ClsGlobal.Val(Model.MinStock.ToString()) + "','" + ClsGlobal.Val(Model.ReorderLevel.ToString()) + "',\n");
                strSql.Append("'" + ClsGlobal.Val(Model.ReorderQty.ToString()) + "','" + ClsGlobal.Val(Model.PercentDisc.ToString()) + "','" + ClsGlobal.Val(Model.MinQty.ToString()) + "','" + ClsGlobal.Val(Model.MinDisc.ToString()) + "','" + ClsGlobal.Val(Model.MaxQty.ToString()) + "','" + ClsGlobal.Val(Model.MaxDisc.ToString()) + "',\n");
                strSql.Append("'" + Model.IsTaxable + "','" + ClsGlobal.Val(Model.TaxRate.ToString()) + "'," + ((Model.PurchaseLedgerId == 0) ? "null" : "'" + Model.PurchaseLedgerId + "'") + "," + ((Model.PurchaseReturnLedgerId == 0) ? "null" : "'" + Model.PurchaseReturnLedgerId + "'") + "," + ((Model.SalesLedgerId == 0) ? "null" : "'" + Model.SalesLedgerId + "'") + ",\n");
                strSql.Append("" + ((Model.SalesReturnLedgerId == 0) ? "null" : "'" + Model.SalesReturnLedgerId + "'") + "," + ((Model.PLOpeningLedgerId == 0) ? "null" : "'" + Model.PLOpeningLedgerId + "'") + "," + ((Model.PLClosingLedgerId == 0) ? "null" : "'" + Model.PLClosingLedgerId + "'") + "," + ((Model.BSClosingLedgerId == 0) ? "null" : "'" + Model.BSClosingLedgerId + "'") + ",\n");
                strSql.Append("'" + Model.DepreciationType + "'," + ((Model.DepreciationLedgerId == 0) ? "null" : "'" + Model.DepreciationLedgerId + "'") + ",'" + ClsGlobal.Val(Model.DepreciationRate.ToString()) + "',null,\n");
                strSql.Append("" + ((Model.DepartmentId == 0) ? "null" : "'" + Model.DepartmentId + "'") + "," + ((Model.DepartmentId1 == 0) ? "null" : "'" + Model.DepartmentId1 + "'") + "," + ((Model.DepartmentId2 == 0) ? "null" : "'" + Model.DepartmentId2 + "'") + "," + ((Model.DepartmentId3 == 0) ? "null" : "'" + Model.DepartmentId3 + "'") + ",N'" + Model.EnterBy.Trim().Replace("'", "''") + "',\n");
                strSql.Append("GetDate(),'" + Model.Status + "'," + ((Model.BarCodeNo2 == "") ? "null" : "N'" + Model.BarCodeNo2.Trim().Replace("'", "''") + "'") + "," + ((Model.BarCodeNo1 == "") ? "null" : "N'" + Model.BarCodeNo1.Trim().Replace("'", "''") + "'") + ",'" + Model.Gadget + "'," + (string.IsNullOrEmpty(Model.ProductModel) ? "null" : "'" + Model.ProductModel + "'") + "\n");

                foreach (SalesProductTerm det in this.ModelSalesProductTerm)
                {
                    strSql.Append("INSERT INTO [ERP].[SalesProductTerm] (ProductId,TermId,Rate) \n");
                    strSql.Append("Select @ProductId,'" + det.TermId + "','" + ClsGlobal.Val(det.Rate.ToString()) + "' \n");
                }
                this.ModelSalesProductTerm.Clear();

                foreach (PurchaseProductTerm det in this.ModelPurchaseProductTerm)
                {
                    strSql.Append("INSERT INTO [ERP].[PurchaseProductTerm] (ProductId,TermId,Rate) \n");
                    strSql.Append("Select @ProductId,'" + det.TermId + "','" + ClsGlobal.Val(det.Rate.ToString()) + "' \n");
                }
                this.ModelPurchaseProductTerm.Clear();

                strSql.Append("SET @VNo =@ProductId");
            }

            else if (Model.Tag == "EDIT")
            {
                strSql.Append("UPDATE ERP.PRODUCT SET ProductDesc= N'" + Model.ProductDesc.Trim().Replace("'", "''") + "',ProductShortName=N'" + Model.ProductShortName.Trim().Replace("'", "''") + "',ProductPrintingName=" + ((Model.ProductPrintingName == "") ? "null" : "N'" + Model.ProductPrintingName.Trim().Replace("'", "''") + "'") + ",\n");
                strSql.Append("GenericName=" + ((Model.GenericName == "") ? "null" : "N'" + Model.GenericName.Trim().Replace("'", "''") + "'") + ",ProductAlias=" + ((Model.ProductAlias == "") ? "null" : "N'" + Model.ProductAlias.Trim().Replace("'", "''") + "'") + ",ProductDescription=" + ((Model.ProductDescription == "") ? "null" : "N'" + Model.ProductDescription.Trim().Replace("'", "''") + "'") + ",ProductCategory=N'" + Model.ProductCategory.Trim().Replace("'", "''") + "',ProductType=N'" + Model.ProductType.Trim().Replace("'", "''") + "',\n");
                strSql.Append("ValuationTech=N'" + Model.ValuationTech.Trim().Replace("'", "''") + "',ProductGrpId= " + ((Model.ProductGrpId == 0) ? "null" : "'" + Model.ProductGrpId + "'") + ",PGrpId1=" + ((Model.PGrpId1 == 0) ? "null" : "'" + Model.PGrpId1 + "'") + ",PGrpId2=" + ((Model.PGrpId2 == 0) ? "null" : "'" + Model.PGrpId2 + "'") + ",ProductSubGrpId=" + ((Model.ProductSubGrpId == 0) ? "null" : "'" + Model.ProductSubGrpId + "'") + ",\n");
                strSql.Append("IsBatchwise='" + Model.IsBatchwise + "',IsSerialWise='" + Model.IsSerialWise + "',IsSizewise='" + Model.IsSizewise + "',IsExpiryDate='" + Model.IsExpiryDate + "',IsManufacturingDate='" + Model.IsManufacturingDate + "',\n");
                strSql.Append("SerialNo=" + ((Model.SerialNo == "") ? "null" : "N'" + Model.SerialNo.Trim().Replace("'", "''") + "'") + ",PartsNo=" + ((Model.PartsNo == "") ? "null" : "N'" + Model.PartsNo.Trim().Replace("'", "''") + "'") + ",ProductUnitId=" + ((Model.ProductUnitId == 0) ? "null" : "'" + Model.ProductUnitId + "'") + ",QtyConv='" + ClsGlobal.Val(Model.QtyConv.ToString()) + "',ProductAltUnitId=" + ((Model.ProductAltUnitId == 0) ? "null" : "'" + Model.ProductAltUnitId + "'") + ",\n");
                strSql.Append("AltConv='" + Model.AltConv + "',BuyRate='" + ClsGlobal.Val(Model.BuyRate.ToString()) + "',SalesRate='" + ClsGlobal.Val(Model.SalesRate.ToString()) + "',Margin1='" + ClsGlobal.Val(Model.Margin1.ToString()) + "',TradeRate='" + ClsGlobal.Val(Model.TradeRate.ToString()) + "',\n");
                strSql.Append("Margin2='" + ClsGlobal.Val(Model.Margin2.ToString()) + "',MRP='" + ClsGlobal.Val(Model.MRP.ToString()) + "',MRRate='" + ClsGlobal.Val(Model.MRRate.ToString()) + "',MaxStock='" + ClsGlobal.Val(Model.MaxStock.ToString()) + "',MinStock='" + ClsGlobal.Val(Model.MinStock.ToString()) + "',ReorderLevel='" + ClsGlobal.Val(Model.ReorderLevel.ToString()) + "',\n");
                strSql.Append("ReorderQty='" + ClsGlobal.Val(Model.ReorderQty.ToString()) + "',PercentDisc='" + ClsGlobal.Val(Model.PercentDisc.ToString()) + "',MinQty='" + ClsGlobal.Val(Model.MinQty.ToString()) + "',MinDisc='" + ClsGlobal.Val(Model.MinDisc.ToString()) + "',MaxQty='" + ClsGlobal.Val(Model.MaxQty.ToString()) + "',MaxDisc='" + ClsGlobal.Val(Model.MaxDisc.ToString()) + "',\n");
                strSql.Append("IsTaxable='" + Model.IsTaxable + "',TaxRate='" + ClsGlobal.Val(Model.TaxRate.ToString()) + "',PurchaseLedgerId=" + ((Model.PurchaseLedgerId == 0) ? "null" : "'" + Model.PurchaseLedgerId + "'") + ",PurchaseReturnLedgerId=" + ((Model.PurchaseReturnLedgerId == 0) ? "null" : "'" + Model.PurchaseReturnLedgerId + "'") + ",SalesLedgerId=" + ((Model.SalesLedgerId == 0) ? "null" : "'" + Model.SalesLedgerId + "'") + ",\n");
                strSql.Append("SalesReturnLedgerId=" + ((Model.SalesReturnLedgerId == 0) ? "null" : "'" + Model.SalesReturnLedgerId + "'") + ",PLOpeningLedgerId=" + ((Model.PLOpeningLedgerId == 0) ? "null" : "'" + Model.PLOpeningLedgerId + "'") + ",PLClosingLedgerId=" + ((Model.PLClosingLedgerId == 0) ? "null" : "'" + Model.PLClosingLedgerId + "'") + ",BSClosingLedgerId=" + ((Model.BSClosingLedgerId == 0) ? "null" : "'" + Model.BSClosingLedgerId + "'") + ",\n");
                strSql.Append("DepreciationType='" + Model.DepreciationType + "',DepreciationLedgerId=" + ((Model.DepreciationLedgerId == 0) ? "null" : "'" + Model.DepreciationLedgerId + "'") + ",DepreciationRate='" + ClsGlobal.Val(Model.DepreciationRate.ToString()) + "',\n");
                strSql.Append("DepartmentId=" + ((Model.DepartmentId == 0) ? "null" : "'" + Model.DepartmentId + "'") + ",DepartmentId1=" + ((Model.DepartmentId1 == 0) ? "null" : "'" + Model.DepartmentId1 + "'") + ",DepartmentId2=" + ((Model.DepartmentId2 == 0) ? "null" : "'" + Model.DepartmentId2 + "'") + ",DepartmentId3=" + ((Model.DepartmentId3 == 0) ? "null" : "'" + Model.DepartmentId3 + "'") + ",EnterBy=N'" + Model.EnterBy.Trim().Replace("'", "''") + "',\n");
                strSql.Append("Status='" + Model.Status + "',BarCodeNo2=" + ((Model.BarCodeNo2 == "") ? "null" : "N'" + Model.BarCodeNo2.Trim().Replace("'", "''") + "'") + ",BarCodeNo1=" + ((Model.BarCodeNo1 == "") ? "null" : "N'" + Model.BarCodeNo1.Trim().Replace("'", "''") + "'") + ",Gadget='" + Model.Gadget + "',ProductModel=" + (string.IsNullOrEmpty(Model.ProductModel) ? "null" : "'" + Model.ProductModel + "'") + "  WHERE ProductId='" + Model.ProductId + "'\n");
                strSql.Append("SET @VNo ='" + Model.ProductId + "'");

                strSql.Append("Delete from [ERP].[SalesProductTerm] where ProductId ='" + Model.ProductId + "' \n");
                strSql.Append("Delete from [ERP].[PurchaseProductTerm] where ProductId ='" + Model.ProductId + "' \n");
                foreach (SalesProductTerm det in this.ModelSalesProductTerm)
                {
                    strSql.Append("INSERT INTO [ERP].[SalesProductTerm] (ProductId,TermId,Rate,LedgerId) \n");
                    strSql.Append("Select '" + Model.ProductId + "','" + det.TermId + "','" + ClsGlobal.Val(det.Rate.ToString()) + "',(select LedgerId from erp.SalesBillingTerm where TermId='" + det.TermId + "') \n");
                }
                this.ModelSalesProductTerm.Clear();

                foreach (PurchaseProductTerm det in this.ModelPurchaseProductTerm)
                {
                    strSql.Append("INSERT INTO [ERP].[PurchaseProductTerm] (ProductId,TermId,Rate,LedgerId) \n");
                    strSql.Append("Select '" + Model.ProductId + "','" + det.TermId + "','" + ClsGlobal.Val(det.Rate.ToString()) + "',(select LedgerId from erp.PurchaseBillingTerm where TermId='" + det.TermId + "') \n");
                }
                this.ModelPurchaseProductTerm.Clear();
            }
            else if (Model.Tag == "DELETE")
            {
                strSql.Append("Delete from [ERP].[SalesProductTerm] where ProductId ='" + Model.ProductId + "' \n");
                strSql.Append("Delete from [ERP].[PurchaseProductTerm] where ProductId ='" + Model.ProductId + "' \n");
                strSql.Append("DELETE FROM ERP.Product WHERE ProductId = '" + Model.ProductId + "' \n");
                strSql.Append("SET @VNo ='1'");
            }

            strSql.Append("\n COMMIT TRANSACTION \n");
            strSql.Append("END TRY \n");
            strSql.Append("BEGIN CATCH \n");
            strSql.Append("ROLLBACK TRANSACTION \n");
            strSql.Append("Set @VNo = '' \n");
            strSql.Append("END CATCH \n");


            SqlParameter[] p = new SqlParameter[1];
            p[0] = new SqlParameter("@VNo", SqlDbType.VarChar, 25)
            {
                Direction = ParameterDirection.Output
            };
            DAL.ExecuteNonQuery(CommandType.Text, strSql.ToString(), p);
            return(p[0].Value.ToString());
        }
예제 #4
0
        private void BtnSave_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(TxtDescription.Text))
            {
                MessageBox.Show("ProductGroup1 Description is Required..!!", "Mr Solution", MessageBoxButtons.OK, MessageBoxIcon.Information);
                TxtDescription.Focus();
                return;
            }
            if (string.IsNullOrEmpty(TxtShortName.Text))
            {
                MessageBox.Show("ProductGroup1 ShortName is Required..!!", "Mr Solution", MessageBoxButtons.OK, MessageBoxIcon.Information);
                TxtShortName.Focus();
                return;
            }

            _objProductGroup.Model.Tag          = _Tag;
            _objProductGroup.Model.ProductGrpId = Convert.ToInt32(TxtDescription.Tag.ToString());
            if ((_Tag == "EDIT" || _Tag == "DELETE") && Convert.ToInt32(TxtDescription.Tag.ToString()) == 0)
            {
                ClearFld();
                return;
            }
            _objProductGroup.Model.ProductGrpDesc        = TxtDescription.Text;
            _objProductGroup.Model.ProductGrpShortName   = TxtShortName.Text;
            _objProductGroup.Model.ProductGrpMargin      = ClsGlobal.ReturnDecimalVal(TxtMargin.Text);
            _objProductGroup.Model.ProductGrpPrinterName = CmbPrinter.Text;
            _objProductGroup.Model.Status  = CbActive.Checked == true ? true : false;
            _objProductGroup.Model.EnterBy = ClsGlobal.LoginUserCode;
            _objProductGroup.Model.Gadget  = "Desktop";
            if (_Tag == "NEW")
            {
                if (ClsGlobal.ConfirmSave == 1)
                {
                    var dialogResult = MessageBox.Show("Are you sure want to Save New Record..??", "Close Form", MessageBoxButtons.YesNo, MessageBoxIcon.Error);
                    if (dialogResult == DialogResult.Yes)
                    {
                        result = _objProductGroup.SaveProductGroup("ProductGroup1");
                    }
                    else
                    {
                        return;
                    }
                }
                else
                {
                    result = _objProductGroup.SaveProductGroup("ProductGroup1");
                }
            }
            else
            {
                result = _objProductGroup.SaveProductGroup("ProductGroup1");
            }
            if (!string.IsNullOrEmpty(result))
            {
                if (_IsNew == 'Y')
                {
                    _NewProductGroup = TxtDescription.Text.Trim();
                    _ProductGrpId    = Convert.ToInt32(result);
                    this.Close();
                }
                else
                {
                    NavMenuDataList = _objProductGroup.GetDataProductGroup(0, "ProductGroup1");
                    MessageBox.Show("Data submit successfully", "Mr Solution", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    ClearFld();
                }
            }
            else
            {
                MessageBox.Show("Error occured during data submit", "Mr Solution", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
예제 #5
0
        private void BtnSave_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(TxtDescription.Text.Trim()))
            {
                MessageBox.Show("Cost Center Description is Required..!!", "Mr Solution", MessageBoxButtons.OK, MessageBoxIcon.Information);
                TxtDescription.Focus();
                return;
            }
            if (string.IsNullOrEmpty(TxtShortName.Text.Trim()))
            {
                MessageBox.Show("Cost Center ShortName is Required..!!", "Mr Solution", MessageBoxButtons.OK, MessageBoxIcon.Information);
                TxtShortName.Focus();
                return;
            }
            _objCostCenter.Model.Tag                 = _Tag;
            _objCostCenter.Model.CostCenterId        = Convert.ToInt32(TxtDescription.Tag.ToString());
            _objCostCenter.Model.CostCenterDesc      = TxtDescription.Text;
            _objCostCenter.Model.CostCenterShortName = TxtShortName.Text;
            _objCostCenter.Model.LedgerId            = ((TxtLedger.Tag.ToString() == "") ? 0 : Convert.ToInt64(TxtLedger.Tag.ToString()));
            _objCostCenter.Model.Address             = TxtAddress.Text;
            _objCostCenter.Model.Country             = TxtCountry.Text;
            _objCostCenter.Model.PhoneNo             = TxtPhoneNo.Text;
            _objCostCenter.Model.MobileNo            = TxtMobileNo.Text;
            _objCostCenter.Model.ContactPerson       = TxtContactPerson.Text;
            _objCostCenter.Model.ContactPersonAdd    = TxtContactAddress.Text;
            _objCostCenter.Model.ContPersonPhoneNo   = TxtContactPhone.Text;
            _objCostCenter.Model.EnterBy             = ClsGlobal.LoginUserCode;
            _objCostCenter.Model.Status              = CbActive.Checked == true ? true : false;
            _objCostCenter.Model.Gadget              = "Desktop";
            if (_Tag == "NEW")
            {
                if (ClsGlobal.ConfirmSave == 1)
                {
                    DialogResult dialogResult = MessageBox.Show("Are you sure want to Save New Record..??", "Close Form", MessageBoxButtons.YesNo, MessageBoxIcon.Error);
                    if (dialogResult == DialogResult.Yes)
                    {
                        result = _objCostCenter.SaveCostCenter();
                    }
                    else
                    {
                        return;
                    }
                }
                else
                {
                    result = _objCostCenter.SaveCostCenter();
                }
            }
            else
            {
                result = _objCostCenter.SaveCostCenter();
            }

            if (!string.IsNullOrEmpty(result))
            {
                if (_IsNew == 'Y')
                {
                    _NewCostCenter = TxtDescription.Text.Trim();
                    _CostCenterId  = Convert.ToInt32(result);
                    Close();
                }
                else
                {
                    NavMenuDataList = _objCostCenter.GetDataCostCenter(0);
                    ClsGlobal.SaveMessage(_Tag);
                    ClearFld();
                    TxtDescription.Focus();
                }
            }
            else
            {
                MessageBox.Show("Cost center already in used.", "Mr Solution", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
예제 #6
0
        private void BtnOk_Click(object sender, EventArgs e)
        {
            if (ClsGlobal.CheckDateInsideCompanyPeriod(Convert.ToDateTime(TxtDate.Text)) == 1)
            {
                ClsGlobal.DateMitiRangeMsg();
                return;
            }

            if (string.IsNullOrEmpty(TxtVoucherNo.Text.Trim()))
            {
                MessageBox.Show("Voucher number cannot be left blank.", "Mr Solution", MessageBoxButtons.OK, MessageBoxIcon.Information);
                TxtVoucherNo.Focus();
                return;
            }
            if (TxtMiti.Text == "  /  /")
            {
                MessageBox.Show("Miti cannot be left blank.", "Mr Solution", MessageBoxButtons.OK, MessageBoxIcon.Information);
                TxtMiti.Focus();
                return;
            }

            if (TxtDate.Text == "  /  /")
            {
                MessageBox.Show("Date cannot be left blank.", "Mr Solution", MessageBoxButtons.OK, MessageBoxIcon.Information);
                TxtDate.Focus();
                return;
            }

            if (Grid.Rows.Count <= 0)
            {
                MessageBox.Show("Invoice details not found.", "Mr Solution", MessageBoxButtons.OK, MessageBoxIcon.Information);
                Grid.Focus();
                return;
            }

            if (Grid.Rows.Count == 1 && Grid.Rows[0].Cells["Particular"].Value == null)
            {
                MessageBox.Show("Invoice details not found.", "Mr Solution", MessageBoxButtons.OK, MessageBoxIcon.Information);
                BtnOk.Enabled = false;
                Grid.Focus();
                return;
            }

            _objPurchaseIndent.Model.EntryFromProject = "Normal";
            _objPurchaseIndent.Model.Gadget           = "Desktop";

            _objPurchaseIndent.Model.VDate       = Convert.ToDateTime(TxtDate.Text);
            _objPurchaseIndent.Model.Tag         = _Tag;
            _objPurchaseIndent.Model.VoucherNo   = TxtVoucherNo.Text.Trim();
            _objPurchaseIndent.Model.VTime       = _objDate.GetServerDateTime();
            _objPurchaseIndent.Model.VMiti       = TxtMiti.Text;
            _objPurchaseIndent.Model.RequestedBy = txtRequestedBy.Text;
            if (!string.IsNullOrEmpty(TxtDepartment.Text))
            {
                string[] dept = TxtDepartment.Tag.ToString().Split('|');
                _objPurchaseIndent.Model.DepartmentId1 = ((dept[0].ToString() == "") ? 0 : Convert.ToInt32(dept[0].ToString()));
                _objPurchaseIndent.Model.DepartmentId2 = ((dept[1].ToString() == "") ? 0 : Convert.ToInt32(dept[1].ToString()));
                _objPurchaseIndent.Model.DepartmentId3 = ((dept[2].ToString() == "") ? 0 : Convert.ToInt32(dept[2].ToString()));
                _objPurchaseIndent.Model.DepartmentId4 = ((dept[3].ToString() == "") ? 0 : Convert.ToInt32(dept[3].ToString()));
            }
            _objPurchaseIndent.Model.Remarks       = TxtRemarks.Text;
            _objPurchaseIndent.Model.BranchId      = ClsGlobal.BranchId;
            _objPurchaseIndent.Model.CompanyUnitId = ClsGlobal.CompanyUnitId;

            PurchaseIndentDetailsViewModel _PurchaseIndentDetails = null;
            int dc = Grid.Rows.Count;

            foreach (DataGridViewRow ro in Grid.Rows)
            {
                if (ro.Cells["Particular"].Value != null)
                {
                    _PurchaseIndentDetails = new PurchaseIndentDetailsViewModel
                    {
                        VoucherNo = _objPurchaseIndent.Model.VoucherNo,
                        Sno       = Grid.Rows.IndexOf(ro) + 1,
                        ProductId = Convert.ToInt32(ro.Cells["ProductId"].Value.ToString())
                    };

                    if (ro.Cells["AltQty"].Value != null)
                    {
                        decimal.TryParse(ro.Cells["AltQty"].Value.ToString().Trim(), out decimal _AltQty);
                        _PurchaseIndentDetails.AltQty = _AltQty;
                    }
                    else
                    {
                        _PurchaseIndentDetails.AltQty = 0;
                    }

                    if (ro.Cells["AltQty"].Value != null)
                    {
                        _PurchaseIndentDetails.ProductAltUnitId = !string.IsNullOrEmpty(ro.Cells["ProductAltUnitId"].Value.ToString()) ? Convert.ToInt32(ro.Cells["ProductAltUnitId"].Value.ToString()) : 0;
                    }

                    _PurchaseIndentDetails.Qty = ro.Cells["Qty"].Value != null?Convert.ToDecimal(ro.Cells["Qty"].Value.ToString().Trim()) : 0;

                    if (ro.Cells["ProductUnitId"].Value != null)
                    {
                        _PurchaseIndentDetails.ProductUnitId = string.IsNullOrEmpty(ro.Cells["ProductUnitId"].Value.ToString()) ? 0 : Convert.ToInt32(ro.Cells["ProductUnitId"].Value.ToString());
                    }
                    else
                    {
                        _PurchaseIndentDetails.ProductUnitId = 0;
                    }

                    _PurchaseIndentDetails.ConversionRatio = ro.Cells["QtyConversion"].Value != null?Convert.ToDecimal(ro.Cells["QtyConversion"].Value.ToString().Trim()) : 0;

                    _PurchaseIndentDetails.Narration = ro.Cells["Narration"].Value.ToString();

                    _objPurchaseIndent.ModelDetails.Add(_PurchaseIndentDetails);
                }
            }

            _objPurchaseIndent.Model.DocId = Convert.ToInt32(TxtVoucherNo.Tag.ToString());
            string output = "";

            if (_Tag == "DELETE")
            {
                DialogResult dialogResult = MessageBox.Show("Are you sure want to Delete Record..??", "Close Form", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                if (dialogResult == DialogResult.No)
                {
                    return;
                }
            }

            if (_Tag == "NEW")
            {
                if (ClsGlobal.ConfirmSave == 1)
                {
                    DialogResult dialogResult = MessageBox.Show("Are you sure want to Save New Record..??", "Close Form", MessageBoxButtons.YesNo, MessageBoxIcon.Error);
                    if (dialogResult == DialogResult.Yes)
                    {
                        output = _objPurchaseIndent.SavePurchaseIndent();
                    }
                }
                else
                {
                    output = _objPurchaseIndent.SavePurchaseIndent();
                }
            }
            else
            {
                output = _objPurchaseIndent.SavePurchaseIndent();
            }

            if (string.IsNullOrEmpty(output))
            {
                MessageBox.Show("Error occurred during data submission.", "Mr Solution", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            else
            {
                if (_Tag == "NEW")
                {
                    MessageBox.Show("Voucher number : " + TxtVoucherNo.Text + " has been generated.", "Mr Solution", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                else if (_Tag == "EDIT")
                {
                    MessageBox.Show("Voucher number : " + TxtVoucherNo.Text + " has been updated.", "Mr Solution", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                else if (_Tag == "DELETE")
                {
                    MessageBox.Show("Voucher number : " + TxtVoucherNo.Text + " has been deleted.", "Mr Solution", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }

                ClearFld();
                if (this._Tag == "NEW")
                {
                    _DocId         = Convert.ToInt32(TxtVoucherNo.Tag.ToString());
                    BtnNew.Enabled = true;
                    BtnNew.PerformClick();
                }
                else if (this._Tag == "EDIT")
                {
                    BtnEdit.Enabled = true;
                    BtnEdit.PerformClick();
                }
                else if (this._Tag == "DELETE")
                {
                    BtnDelete.Enabled = true;
                    BtnDelete.PerformClick();
                }
            }
        }