예제 #1
0
 public Pos_Product GetPos_ProductFromReader(IDataReader reader)
 {
     try
     {
         Pos_Product pos_Product = new Pos_Product
                                   (
             (int)reader["Pos_ProductID"],
             (int)reader["ProductID"],
             (int)reader["ReferenceID"],
             (int)reader["Pos_ProductTypeID"],
             reader["Inv_UtilizationDetailsIDs"].ToString(),
             (int)reader["ProductStatusID"],
             reader["ProductName"].ToString(),
             reader["DesignCode"].ToString(),
             (int)reader["Pos_SizeID"],
             (int)reader["Pos_BrandID"],
             (int)reader["Inv_QuantityUnitID"],
             (decimal)reader["FabricsCost"],
             (decimal)reader["AccesoriesCost"],
             (decimal)reader["Overhead"],
             (decimal)reader["OthersCost"],
             (decimal)reader["PurchasePrice"],
             (decimal)reader["SalePrice"],
             (decimal)reader["OldSalePrice"],
             reader["Note"].ToString(),
             reader["BarCode"].ToString(),
             (int)reader["Pos_ColorID"],
             (int)reader["Pos_FabricsTypeID"],
             reader["StyleCode"].ToString(),
             reader["Pic1"].ToString(),
             reader["Pic2"].ToString(),
             reader["Pic3"].ToString(),
             (decimal)reader["VatPercentage"],
             (bool)reader["IsVatExclusive"],
             (decimal)reader["DiscountPercentage"],
             (decimal)reader["DiscountAmount"],
             reader["FabricsNo"].ToString(),
             reader["ExtraField1"].ToString(),
             reader["ExtraField2"].ToString(),
             reader["ExtraField3"].ToString(),
             reader["ExtraField4"].ToString(),
             reader["ExtraField5"].ToString(),
             reader["ExtraField6"].ToString(),
             reader["ExtraField7"].ToString(),
             reader["ExtraField8"].ToString(),
             reader["ExtraField9"].ToString(),
             reader["ExtraField10"].ToString(),
             (int)reader["AddedBy"],
             (DateTime)reader["AddedDate"],
             (int)reader["UpdatedBy"],
             (DateTime)reader["UpdatedDate"],
             (int)reader["RowStatusID"]
                                   );
         return(pos_Product);
     }
     catch (Exception ex)
     {
         return(null);
     }
 }
예제 #2
0
 public static Pos_Product GetPos_ProductByID(int id)
 {
     Pos_Product pos_Product = new Pos_Product();
     SqlPos_ProductProvider sqlPos_ProductProvider = new SqlPos_ProductProvider();
     pos_Product = sqlPos_ProductProvider.GetPos_ProductByID(id);
     return pos_Product;
 }
예제 #3
0
    public static Pos_Product GetPos_ProductByID(int id)
    {
        Pos_Product            pos_Product            = new Pos_Product();
        SqlPos_ProductProvider sqlPos_ProductProvider = new SqlPos_ProductProvider();

        pos_Product = sqlPos_ProductProvider.GetPos_ProductByID(id);
        return(pos_Product);
    }
예제 #4
0
    public bool UpdatePos_Product(Pos_Product pos_Product)
    {
        using (SqlConnection connection = new SqlConnection(this.ConnectionString))
        {
            SqlCommand cmd = new SqlCommand("GP_UpdatePos_Product", connection);
            cmd.CommandType = CommandType.StoredProcedure;
            cmd.Parameters.Add("@Pos_ProductID", SqlDbType.Int).Value     = pos_Product.Pos_ProductID;
            cmd.Parameters.Add("@ProductID", SqlDbType.Int).Value         = pos_Product.ProductID;
            cmd.Parameters.Add("@ReferenceID", SqlDbType.Int).Value       = pos_Product.ReferenceID;
            cmd.Parameters.Add("@Pos_ProductTypeID", SqlDbType.Int).Value = pos_Product.Pos_ProductTypeID;
            cmd.Parameters.Add("@Inv_UtilizationDetailsIDs", SqlDbType.NVarChar).Value = pos_Product.Inv_UtilizationDetailsIDs;
            cmd.Parameters.Add("@ProductStatusID", SqlDbType.Int).Value        = pos_Product.ProductStatusID;
            cmd.Parameters.Add("@ProductName", SqlDbType.NVarChar).Value       = pos_Product.ProductName;
            cmd.Parameters.Add("@DesignCode", SqlDbType.NVarChar).Value        = pos_Product.DesignCode;
            cmd.Parameters.Add("@Pos_SizeID", SqlDbType.Int).Value             = pos_Product.Pos_SizeID;
            cmd.Parameters.Add("@Pos_BrandID", SqlDbType.Int).Value            = pos_Product.Pos_BrandID;
            cmd.Parameters.Add("@Inv_QuantityUnitID", SqlDbType.Int).Value     = pos_Product.Inv_QuantityUnitID;
            cmd.Parameters.Add("@FabricsCost", SqlDbType.Decimal).Value        = pos_Product.FabricsCost;
            cmd.Parameters.Add("@AccesoriesCost", SqlDbType.Decimal).Value     = pos_Product.AccesoriesCost;
            cmd.Parameters.Add("@Overhead", SqlDbType.Decimal).Value           = pos_Product.Overhead;
            cmd.Parameters.Add("@OthersCost", SqlDbType.Decimal).Value         = pos_Product.OthersCost;
            cmd.Parameters.Add("@PurchasePrice", SqlDbType.Decimal).Value      = pos_Product.PurchasePrice;
            cmd.Parameters.Add("@SalePrice", SqlDbType.Decimal).Value          = pos_Product.SalePrice;
            cmd.Parameters.Add("@OldSalePrice", SqlDbType.Decimal).Value       = pos_Product.OldSalePrice;
            cmd.Parameters.Add("@Note", SqlDbType.NText).Value                 = pos_Product.Note;
            cmd.Parameters.Add("@BarCode", SqlDbType.NVarChar).Value           = pos_Product.BarCode;
            cmd.Parameters.Add("@Pos_ColorID", SqlDbType.Int).Value            = pos_Product.Pos_ColorID;
            cmd.Parameters.Add("@Pos_FabricsTypeID", SqlDbType.Int).Value      = pos_Product.Pos_FabricsTypeID;
            cmd.Parameters.Add("@StyleCode", SqlDbType.NVarChar).Value         = pos_Product.StyleCode;
            cmd.Parameters.Add("@Pic1", SqlDbType.NVarChar).Value              = pos_Product.Pic1;
            cmd.Parameters.Add("@Pic2", SqlDbType.NVarChar).Value              = pos_Product.Pic2;
            cmd.Parameters.Add("@Pic3", SqlDbType.NVarChar).Value              = pos_Product.Pic3;
            cmd.Parameters.Add("@VatPercentage", SqlDbType.Decimal).Value      = pos_Product.VatPercentage;
            cmd.Parameters.Add("@IsVatExclusive", SqlDbType.Bit).Value         = pos_Product.IsVatExclusive;
            cmd.Parameters.Add("@DiscountPercentage", SqlDbType.Decimal).Value = pos_Product.DiscountPercentage;
            cmd.Parameters.Add("@DiscountAmount", SqlDbType.Decimal).Value     = pos_Product.DiscountAmount;
            cmd.Parameters.Add("@FabricsNo", SqlDbType.NVarChar).Value         = pos_Product.FabricsNo;
            cmd.Parameters.Add("@ExtraField1", SqlDbType.NVarChar).Value       = pos_Product.ExtraField1;
            cmd.Parameters.Add("@ExtraField2", SqlDbType.NVarChar).Value       = pos_Product.ExtraField2;
            cmd.Parameters.Add("@ExtraField3", SqlDbType.NVarChar).Value       = pos_Product.ExtraField3;
            cmd.Parameters.Add("@ExtraField4", SqlDbType.NVarChar).Value       = pos_Product.ExtraField4;
            cmd.Parameters.Add("@ExtraField5", SqlDbType.NVarChar).Value       = pos_Product.ExtraField5;
            cmd.Parameters.Add("@ExtraField6", SqlDbType.NVarChar).Value       = pos_Product.ExtraField6;
            cmd.Parameters.Add("@ExtraField7", SqlDbType.NVarChar).Value       = pos_Product.ExtraField7;
            cmd.Parameters.Add("@ExtraField8", SqlDbType.NVarChar).Value       = pos_Product.ExtraField8;
            cmd.Parameters.Add("@ExtraField9", SqlDbType.NVarChar).Value       = pos_Product.ExtraField9;
            cmd.Parameters.Add("@ExtraField10", SqlDbType.NVarChar).Value      = pos_Product.ExtraField10;
            cmd.Parameters.Add("@AddedBy", SqlDbType.Int).Value                = pos_Product.AddedBy;
            cmd.Parameters.Add("@AddedDate", SqlDbType.DateTime).Value         = pos_Product.AddedDate;
            cmd.Parameters.Add("@UpdatedBy", SqlDbType.Int).Value              = pos_Product.UpdatedBy;
            cmd.Parameters.Add("@UpdatedDate", SqlDbType.DateTime).Value       = pos_Product.UpdatedDate;
            cmd.Parameters.Add("@RowStatusID", SqlDbType.Int).Value            = pos_Product.RowStatusID;
            connection.Open();

            int result = cmd.ExecuteNonQuery();
            return(result == 1);
        }
    }
예제 #5
0
    protected void btnUpdate_Click(object sender, EventArgs e)
    {
        Pos_Product pos_Product = new Pos_Product();

        pos_Product = Pos_ProductManager.GetPos_ProductByID(Int32.Parse(Request.QueryString["pos_ProductID"]));
        Pos_Product tempPos_Product = new Pos_Product();

        tempPos_Product.Pos_ProductID = pos_Product.Pos_ProductID;

        tempPos_Product.ProductID                 = Int32.Parse(ddlProduct.SelectedValue);
        tempPos_Product.ReferenceID               = Int32.Parse(ddlReference.SelectedValue);
        tempPos_Product.Pos_ProductTypeID         = Int32.Parse(ddlPos_ProductType.SelectedValue);
        tempPos_Product.Inv_UtilizationDetailsIDs = Int32.Parse(ddlInv_UtilizationDetails.SelectedValue);
        tempPos_Product.ProductStatusID           = Int32.Parse(ddlProductStatus.SelectedValue);
        tempPos_Product.ProductName               = txtProductName.Text;
        tempPos_Product.DesignCode                = txtDesignCode.Text;
        tempPos_Product.Pos_SizeID                = Int32.Parse(ddlPos_Size.SelectedValue);
        tempPos_Product.Pos_BrandID               = Int32.Parse(ddlPos_Brand.SelectedValue);
        tempPos_Product.Inv_QuantityUnitID        = Int32.Parse(ddlInv_QuantityUnit.SelectedValue);
        tempPos_Product.FabricsCost               = Decimal.Parse(txtFabricsCost.Text);
        tempPos_Product.AccesoriesCost            = Decimal.Parse(txtAccesoriesCost.Text);
        tempPos_Product.Overhead           = Decimal.Parse(txtOverhead.Text);
        tempPos_Product.OthersCost         = Decimal.Parse(txtOthersCost.Text);
        tempPos_Product.PurchasePrice      = Decimal.Parse(txtPurchasePrice.Text);
        tempPos_Product.SalePrice          = Decimal.Parse(txtSalePrice.Text);
        tempPos_Product.OldSalePrice       = Decimal.Parse(txtOldSalePrice.Text);
        tempPos_Product.Note               = txtNote.Text;
        tempPos_Product.BarCode            = txtBarCode.Text;
        tempPos_Product.Pos_ColorID        = Int32.Parse(ddlPos_Color.SelectedValue);
        tempPos_Product.Pos_FabricsTypeID  = Int32.Parse(ddlPos_FabricsType.SelectedValue);
        tempPos_Product.StyleCode          = txtStyleCode.Text;
        tempPos_Product.Pic1               = txtPic1.Text;
        tempPos_Product.Pic2               = txtPic2.Text;
        tempPos_Product.Pic3               = txtPic3.Text;
        tempPos_Product.VatPercentage      = Decimal.Parse(txtVatPercentage.Text);
        tempPos_Product.IsVatExclusive     = cbIsVatExclusive.Checked;
        tempPos_Product.DiscountPercentage = Decimal.Parse(txtDiscountPercentage.Text);
        tempPos_Product.DiscountAmount     = Decimal.Parse(txtDiscountAmount.Text);
        tempPos_Product.FabricsNo          = txtFabricsNo.Text;
        tempPos_Product.ExtraField1        = txtExtraField1.Text;
        tempPos_Product.ExtraField2        = txtExtraField2.Text;
        tempPos_Product.ExtraField3        = txtExtraField3.Text;
        tempPos_Product.ExtraField4        = txtExtraField4.Text;
        tempPos_Product.ExtraField5        = txtExtraField5.Text;
        tempPos_Product.ExtraField6        = txtExtraField6.Text;
        tempPos_Product.ExtraField7        = txtExtraField7.Text;
        tempPos_Product.ExtraField8        = txtExtraField8.Text;
        tempPos_Product.ExtraField9        = txtExtraField9.Text;
        tempPos_Product.ExtraField10       = txtExtraField10.Text;
        tempPos_Product.AddedBy            = Int32.Parse(txtAddedBy.Text);
        tempPos_Product.AddedDate          = DateTime.Now;
        tempPos_Product.UpdatedBy          = Int32.Parse(txtUpdatedBy.Text);
        tempPos_Product.UpdatedDate        = txtUpdatedDate.Text;
        tempPos_Product.RowStatusID        = Int32.Parse(ddlRowStatus.SelectedValue);
        bool result = Pos_ProductManager.UpdatePos_Product(tempPos_Product);

        Response.Redirect("AdminPos_ProductDisplay.aspx");
    }
예제 #6
0
    private void showPos_ProductData()
    {
        Pos_Product pos_Product = new Pos_Product();

        pos_Product = Pos_ProductManager.GetPos_ProductByID(Int32.Parse(Request.QueryString["pos_ProductID"]));

        ddlProduct.SelectedValue                = pos_Product.ProductID.ToString();
        ddlReference.SelectedValue              = pos_Product.ReferenceID.ToString();
        ddlPos_ProductType.SelectedValue        = pos_Product.Pos_ProductTypeID.ToString();
        ddlInv_UtilizationDetails.SelectedValue = pos_Product.Inv_UtilizationDetailsIDs.ToString();
        ddlProductStatus.SelectedValue          = pos_Product.ProductStatusID.ToString();
        txtProductName.Text               = pos_Product.ProductName;
        txtDesignCode.Text                = pos_Product.DesignCode;
        ddlPos_Size.SelectedValue         = pos_Product.Pos_SizeID.ToString();
        ddlPos_Brand.SelectedValue        = pos_Product.Pos_BrandID.ToString();
        ddlInv_QuantityUnit.SelectedValue = pos_Product.Inv_QuantityUnitID.ToString();
        txtFabricsCost.Text               = pos_Product.FabricsCost.ToString();
        txtAccesoriesCost.Text            = pos_Product.AccesoriesCost.ToString();
        txtOverhead.Text                 = pos_Product.Overhead.ToString();
        txtOthersCost.Text               = pos_Product.OthersCost.ToString();
        txtPurchasePrice.Text            = pos_Product.PurchasePrice.ToString();
        txtSalePrice.Text                = pos_Product.SalePrice.ToString();
        txtOldSalePrice.Text             = pos_Product.OldSalePrice.ToString();
        txtNote.Text                     = pos_Product.Note;
        txtBarCode.Text                  = pos_Product.BarCode;
        ddlPos_Color.SelectedValue       = pos_Product.Pos_ColorID.ToString();
        ddlPos_FabricsType.SelectedValue = pos_Product.Pos_FabricsTypeID.ToString();
        txtStyleCode.Text                = pos_Product.StyleCode;
        txtPic1.Text                     = pos_Product.Pic1;
        txtPic2.Text                     = pos_Product.Pic2;
        txtPic3.Text                     = pos_Product.Pic3;
        txtVatPercentage.Text            = pos_Product.VatPercentage.ToString();
        cbIsVatExclusive.Checked         = pos_Product.IsFeature;
        txtDiscountPercentage.Text       = pos_Product.DiscountPercentage.ToString();
        txtDiscountAmount.Text           = pos_Product.DiscountAmount.ToString();
        txtFabricsNo.Text                = pos_Product.FabricsNo;
        txtExtraField1.Text              = pos_Product.ExtraField1;
        txtExtraField2.Text              = pos_Product.ExtraField2;
        txtExtraField3.Text              = pos_Product.ExtraField3;
        txtExtraField4.Text              = pos_Product.ExtraField4;
        txtExtraField5.Text              = pos_Product.ExtraField5;
        txtExtraField6.Text              = pos_Product.ExtraField6;
        txtExtraField7.Text              = pos_Product.ExtraField7;
        txtExtraField8.Text              = pos_Product.ExtraField8;
        txtExtraField9.Text              = pos_Product.ExtraField9;
        txtExtraField10.Text             = pos_Product.ExtraField10;
        txtAddedBy.Text                  = pos_Product.AddedBy.ToString();
        txtUpdatedBy.Text                = pos_Product.UpdatedBy.ToString();
        txtUpdatedDate.Text              = pos_Product.UpdatedDate;
        ddlRowStatus.SelectedValue       = pos_Product.RowStatusID.ToString();
    }
예제 #7
0
파일: Sales.aspx.cs 프로젝트: anam/gp-HO
    protected void btnAddCardPayment_Click(object sender, EventArgs e)
    {
        List<Pos_Product> paymentList = new List<Pos_Product>();
        decimal totalAmount = 0;
        foreach (GridViewRow gvr in gvPayment.Rows)
        {
            HiddenField hfSerial = (HiddenField)gvr.FindControl("hfSerial");
            HiddenField hfIssueFromID = (HiddenField)gvr.FindControl("hfIssueFromID");
            Label lblCardNo = (Label)gvr.FindControl("lblCardNo");
            Label lblCardType = (Label)gvr.FindControl("lblCardType");
            Label lblIssueFrom = (Label)gvr.FindControl("lblIssueFrom");
            Label lblAmount = (Label)gvr.FindControl("lblAmount");

            Pos_Product PaymentGrid = new Pos_Product();
            PaymentGrid.Pos_ProductID = int.Parse(hfSerial.Value);
            PaymentGrid.ExtraField1 = lblCardNo.Text;
            PaymentGrid.ExtraField2 = lblCardType.Text;
            PaymentGrid.ExtraField3 = lblIssueFrom.Text;
            PaymentGrid.ExtraField4 = hfIssueFromID.Value;
            PaymentGrid.ExtraField5 = lblAmount.Text;
            totalAmount += decimal.Parse(lblAmount.Text);

            paymentList.Add(PaymentGrid);
        }

        Pos_Product newPayment = new Pos_Product();
        newPayment.Pos_ProductID = paymentList.Count;
        newPayment.ExtraField1 = txtCardNoPayment.Text;
        newPayment.ExtraField2 = ddlCardType.SelectedValue;
        newPayment.ExtraField3 = ddlIssueBank.SelectedItem.Text;
        newPayment.ExtraField4 = ddlIssueBank.SelectedValue;
        newPayment.ExtraField5 = txtAmount.Text;
        totalAmount += decimal.Parse(txtAmount.Text);

        paymentList.Add(newPayment);

        gvPayment.DataSource = paymentList;
        gvPayment.DataBind();

        txtCardAmount.Text = totalAmount.ToString("0,0.00");
        ((Label)gvPayment.FooterRow.FindControl("lblTotalCardAmountFooter")).Text = totalAmount.ToString("0,0.00") ;
        txtCashAmount_TextChanged(this, new EventArgs());
    }
    private void loadData()
    {
        string fromDate = (Request.QueryString["FromDate"] != null ? Request.QueryString["FromDate"].ToString() : "");
        string toDate = (Request.QueryString["ToDate"] != null ? Request.QueryString["ToDate"].ToString() : "");
        lblStockDate.Text = DateTime.Parse(fromDate).ToString("dd/MM/yyyy") + " to " + DateTime.Parse(toDate).ToString("dd/MM/yyyy");
        //purchase info
        string sql = @"declare @FromDate datetime
        declare @ToDate datetime
        set @FromDate='" + fromDate + @"'
        set @ToDate='" + toDate + @"'

        ";

        List<Pos_TransactionType> allTransactionTypeRow = Pos_TransactionTypeManager.GetAllPos_TransactionTypes();

        foreach (Pos_TransactionType type in allTransactionTypeRow)
        {
           try
                {
                    if (int.Parse(type.CentralStockFormula) != 0)
                    {

                sql += @"--" + type.TransactionTypeName + @" Stock
                    Select Pos_Transaction.Quantity as Qty, Pos_Product.SalePrice  as QtyPrice,Pos_Product.Pos_ProductID as ProductID
                    ,ACC_ChartOfAccountLabel4.ChartOfAccountLabel4Text,Pos_Product.BarCode as ExtraField1
                     from Pos_Transaction
                    inner join Pos_Product on pos_Product.Pos_ProductID = Pos_Transaction.Pos_ProductID
                    inner join Pos_TransactionMaster on Pos_TransactionMaster.Pos_TransactionMasterID = Pos_Transaction.Pos_ProductTransactionMasterID
                    inner join ACC_ChartOfAccountLabel4 on Pos_Product.ProductID = ACC_ChartOfAccountLabel4.ACC_ChartOfAccountLabel4ID
                    where Pos_Transaction.Pos_ProductTrasactionTypeID =" + type.Pos_TransactionTypeID + @" and Pos_Product.ProductID="+Request.QueryString["ProductID"]+@"
                    --and Pos_Transaction.WorkStationID=1
                    and Pos_Transaction.RowStatusID=1
                    " + (type.Pos_TransactionTypeID == 10 ? " and Pos_TransactionMaster.ExtraField5 <> 'Pending'" : "") + @"
                    and Pos_TransactionMaster.TransactionDate < @FromDate
                    --group by Pos_Product.ProductID,ACC_ChartOfAccountLabel4.ChartOfAccountLabel4Text,ACC_ChartOfAccountLabel4.ExtraField1
                    order by ACC_ChartOfAccountLabel4.ChartOfAccountLabel4Text,Pos_Product.BarCode

                    -- " + type.TransactionTypeName + @" Current
                    Select Pos_Transaction.Quantity as Qty, Pos_Product.SalePrice  as QtyPrice,Pos_Product.Pos_ProductID as ProductID
                    ,ACC_ChartOfAccountLabel4.ChartOfAccountLabel4Text,Pos_Product.BarCode as ExtraField1
                     from Pos_Transaction
                    inner join Pos_Product on pos_Product.Pos_ProductID = Pos_Transaction.Pos_ProductID
                    inner join Pos_TransactionMaster on Pos_TransactionMaster.Pos_TransactionMasterID = Pos_Transaction.Pos_ProductTransactionMasterID
                    inner join ACC_ChartOfAccountLabel4 on Pos_Product.ProductID = ACC_ChartOfAccountLabel4.ACC_ChartOfAccountLabel4ID
                    where Pos_Transaction.Pos_ProductTrasactionTypeID =" + type.Pos_TransactionTypeID + @" and Pos_Product.ProductID=" + Request.QueryString["ProductID"] + @"
                    --and Pos_Transaction.WorkStationID=1
                    and Pos_Transaction.RowStatusID=1
                    " + (type.Pos_TransactionTypeID == 10 ? " and Pos_TransactionMaster.ExtraField5 <> 'Pending'" : "") + @"
                    and Pos_TransactionMaster.TransactionDate >= @FromDate and Pos_TransactionMaster.TransactionDate <= @ToDate
                    --group by Pos_Product.ProductID,ACC_ChartOfAccountLabel4.ChartOfAccountLabel4Text,ACC_ChartOfAccountLabel4.ExtraField1
                    order by ACC_ChartOfAccountLabel4.ChartOfAccountLabel4Text,Pos_Product.BarCode
                    ";
                    }
                }
           catch (Exception ex)
           { }
        }

        //Need To sort this list by ExtraField5
        List<Pos_TransactionType> allTransactionType = allTransactionTypeRow.OrderBy(o => o.Sorting).ToList();

        DataSet ds= CommonManager.SQLExec(sql);

        List<Pos_Product> Products = new List<Pos_Product>();

        foreach (DataTable tbl in ds.Tables)
        {
            foreach (DataRow dr in tbl.Rows)
            {
                Pos_Product newProduct = new Pos_Product();
                bool isFound=false;
                //foreach (Pos_Product pos_Product in Products)
                //{
                //    if (dr["ProductID"].ToString() == pos_Product.ProductID.ToString())
                //    {
                //        isFound = true;
                //        break;
                //    }
                //}

                if (!isFound)
                {
                    newProduct.ProductID = int.Parse(dr["ProductID"].ToString());
                    newProduct.BarCode = dr["ExtraField1"].ToString();
                    newProduct.ProductName = dr["ChartOfAccountLabel4Text"].ToString();
                    newProduct.Production_Stock=0;
                    newProduct.Production_Current=0;
                    newProduct.ProductionAdjustment_Stock=0;
                    newProduct.ProductionAdjustment_Current=0;
                    newProduct.Purchase_Stock=0;
                    newProduct.Purchase_Current=0;
                    newProduct.PurchaseAdjustment_Stock=0;
                    newProduct.PurchaseAdjustment_Current=0;
                    newProduct.PurchaseReturn_Stock=0;
                    newProduct.PurchaseReturn_Current=0;
                    newProduct.Lost_HO_Stock=0;
                    newProduct.Lost_HO_Current=0;
                    newProduct.Wastage_HO_Stock=0;
                    newProduct.Wastage_HO_Current=0;
                    newProduct.Issue_Wash_HO_Stock=0;
                    newProduct.Issue_Wash_HO_Current=0;
                    newProduct.Back_After_Wash_Stock=0;
                    newProduct.Back_After_Wash_Current=0;
                    newProduct.Issue_for_Repair_Stock=0;
                    newProduct.Issue_for_Repair_Current=0;
                    newProduct.Back_after_repair_Stock=0;
                    newProduct.Back_after_repair_Current=0;
                    newProduct.Issue_to_Showroom_Stock=0;
                    newProduct.Issue_to_Showroom_Current=0;
                    newProduct.Issue_Return_HO_Stock=0;
                    newProduct.Issue_Return_HO_Current=0;
                    newProduct.Send_another_Showroom_Stock=0;
                    newProduct.Send_another_Showroom_Current=0;
                    newProduct.Received_another_Showroom_Stock=0;
                    newProduct.Received_another_Showroom_Current=0;
                    newProduct.Sales_Stock=0;
                    newProduct.Sales_Current=0;
                    newProduct.Sales_return_Stock=0;
                    newProduct.Sales_return_Current=0;
                    newProduct.Gift_HO_Stock=0;
                    newProduct.Gift_HO_Current=0;
                    newProduct.Gift_Showroom_Stock=0;
                    newProduct.Gift_Showroom_Current=0;
                    newProduct.Send_wash_Showroom_Stock=0;
                    newProduct.Send_wash_Showroom_Current=0;
                    newProduct.Received_wash_Showroom_Stock=0;
                    newProduct.Received_wash_Showroom_Current=0;
                    newProduct.Send_repair_Showroom_Stock=0;
                    newProduct.Send_repair_Showroom_Current=0;
                    newProduct.Received_repair_Showroom_Stock=0;
                    newProduct.Received_repair_Showroom_Current=0;
                    newProduct.Lost_Showroom_Stock=0;
                    newProduct.Lost_Showroom_Current=0;
                    newProduct.Wastage_Showroom_Stock=0;
                    newProduct.Wastage_Showroom_Current=0;
                    newProduct.Adjustment_Add_Showroom_Stock=0;
                    newProduct.Adjustment_Add_Showroom_Current=0;
                    newProduct.Adjustment_Sub_Showroom_Stock=0;
                    newProduct.Adjustment_Sub_Showroom_Current=0;

                    newProduct.Production_Stock_price = 0;
                    newProduct.Production_Current_price = 0;
                    newProduct.ProductionAdjustment_Stock_price = 0;
                    newProduct.ProductionAdjustment_Current_price = 0;
                    newProduct.Purchase_Stock_price = 0;
                    newProduct.Purchase_Current_price = 0;
                    newProduct.PurchaseAdjustment_Stock_price = 0;
                    newProduct.PurchaseAdjustment_Current_price = 0;
                    newProduct.PurchaseReturn_Stock_price = 0;
                    newProduct.PurchaseReturn_Current_price = 0;
                    newProduct.Lost_HO_Stock_price = 0;
                    newProduct.Lost_HO_Current_price = 0;
                    newProduct.Wastage_HO_Stock_price = 0;
                    newProduct.Wastage_HO_Current_price = 0;
                    newProduct.Issue_Wash_HO_Stock_price = 0;
                    newProduct.Issue_Wash_HO_Current_price = 0;
                    newProduct.Back_After_Wash_Stock_price = 0;
                    newProduct.Back_After_Wash_Current_price = 0;
                    newProduct.Issue_for_Repair_Stock_price = 0;
                    newProduct.Issue_for_Repair_Current_price = 0;
                    newProduct.Back_after_repair_Stock_price = 0;
                    newProduct.Back_after_repair_Current_price = 0;
                    newProduct.Issue_to_Showroom_Stock_price = 0;
                    newProduct.Issue_to_Showroom_Current_price = 0;
                    newProduct.Issue_Return_HO_Stock_price = 0;
                    newProduct.Issue_Return_HO_Current_price = 0;
                    newProduct.Send_another_Showroom_Stock_price = 0;
                    newProduct.Send_another_Showroom_Current_price = 0;
                    newProduct.Received_another_Showroom_Stock_price = 0;
                    newProduct.Received_another_Showroom_Current_price = 0;
                    newProduct.Sales_Stock_price = 0;
                    newProduct.Sales_Current_price = 0;
                    newProduct.Sales_return_Stock_price = 0;
                    newProduct.Sales_return_Current_price = 0;
                    newProduct.Gift_HO_Stock_price = 0;
                    newProduct.Gift_HO_Current_price = 0;
                    newProduct.Gift_Showroom_Stock_price = 0;
                    newProduct.Gift_Showroom_Current_price = 0;
                    newProduct.Send_wash_Showroom_Stock_price = 0;
                    newProduct.Send_wash_Showroom_Current_price = 0;
                    newProduct.Received_wash_Showroom_Stock_price = 0;
                    newProduct.Received_wash_Showroom_Current_price = 0;
                    newProduct.Send_repair_Showroom_Stock_price = 0;
                    newProduct.Send_repair_Showroom_Current_price = 0;
                    newProduct.Received_repair_Showroom_Stock_price = 0;
                    newProduct.Received_repair_Showroom_Current_price = 0;
                    newProduct.Lost_Showroom_Stock_price = 0;
                    newProduct.Lost_Showroom_Current_price = 0;
                    newProduct.Wastage_Showroom_Stock_price = 0;
                    newProduct.Wastage_Showroom_Current_price = 0;
                    newProduct.Adjustment_Add_Showroom_Stock_price = 0;
                    newProduct.Adjustment_Add_Showroom_Current_price = 0;
                    newProduct.Adjustment_Sub_Showroom_Stock_price = 0;
                    newProduct.Adjustment_Sub_Showroom_Current_price = 0;

                    Products.Add(newProduct);
                }
            }

        }

        sql = "";
        foreach (Pos_Product pos_Product in Products)
        {
            sql += @"select top 1 Inv_QuantityUnit.QuantityUnitName,'" +pos_Product.ProductID.ToString()+ @"' as ProductID from Pos_Product
                        inner join Inv_QuantityUnit on Inv_QuantityUnit.Inv_QuantityUnitID= Pos_Product.Inv_QuantityUnitID
                        where Pos_Product.ProductID=" + pos_Product.ProductID.ToString() + ";";
        }

        DataSet ds2 = CommonManager.SQLExec(sql);

        //for (int i = 0; i < Products.Count; i++)
        //{
        //    if (ds2.Tables[i].Rows[0]["ProductID"].ToString() == Products[i].Pos_ProductID.ToString())
        //    {
        //        Products[i].Inv_QuantityUniteName = ds2.Tables[i].Rows[0]["QuantityUnitName"].ToString();
        //    }
        //}

        foreach (Pos_Product pos_Product in Products)
        {
            //Production stock
            foreach (DataRow dr in ds.Tables[0].Rows)
            {
                if (pos_Product.ProductID.ToString() == dr["ProductID"].ToString())
                {
                    pos_Product.Production_Stock = decimal.Parse(dr["Qty"].ToString());
                    pos_Product.Production_Stock_price = decimal.Parse(dr["QtyPrice"].ToString());
                    break;
                }
            }

            //Production Current
            foreach (DataRow dr in ds.Tables[1].Rows)
            {
                if (pos_Product.ProductID.ToString() == dr["ProductID"].ToString())
                {
                    pos_Product.Production_Current = decimal.Parse(dr["Qty"].ToString());
                    pos_Product.Production_Current_price = decimal.Parse(dr["QtyPrice"].ToString());
                    break;
                }
            }

            //ProductionAdjustment_Stock
            foreach (DataRow dr in ds.Tables[2].Rows)
            {
                if (pos_Product.ProductID.ToString() == dr["ProductID"].ToString())
                {
                    pos_Product.ProductionAdjustment_Stock = decimal.Parse(dr["Qty"].ToString());
                    pos_Product.ProductionAdjustment_Stock_price = decimal.Parse(dr["QtyPrice"].ToString());
                    break;
                }
            }

            //ProductionAdjustment_Current
            foreach (DataRow dr in ds.Tables[3].Rows)
            {
                if (pos_Product.ProductID.ToString() == dr["ProductID"].ToString())
                {
                    pos_Product.ProductionAdjustment_Current = decimal.Parse(dr["Qty"].ToString());
                    pos_Product.ProductionAdjustment_Current_price = decimal.Parse(dr["QtyPrice"].ToString());
                    break;
                }
            }

            //Lost_HO_Stock
            foreach (DataRow dr in ds.Tables[4].Rows)
            {
                if (pos_Product.ProductID.ToString() == dr["ProductID"].ToString())
                {
                    pos_Product.Lost_HO_Stock = decimal.Parse(dr["Qty"].ToString());
                    pos_Product.Lost_HO_Stock_price = decimal.Parse(dr["QtyPrice"].ToString());
                    break;
                }
            }

            //Lost_HO_Current
            foreach (DataRow dr in ds.Tables[5].Rows)
            {
                if (pos_Product.ProductID.ToString() == dr["ProductID"].ToString())
                {
                    pos_Product.Lost_HO_Current = decimal.Parse(dr["Qty"].ToString());
                    pos_Product.Lost_HO_Current_price = decimal.Parse(dr["QtyPrice"].ToString());
                    break;
                }
            }

            //Wastage_HO_Stock
            foreach (DataRow dr in ds.Tables[6].Rows)
            {
                if (pos_Product.ProductID.ToString() == dr["ProductID"].ToString())
                {
                    pos_Product.Wastage_HO_Stock = decimal.Parse(dr["Qty"].ToString());
                    pos_Product.Wastage_HO_Stock_price = decimal.Parse(dr["QtyPrice"].ToString());
                    break;
                }
            }

            //Wastage_HO_Current
            foreach (DataRow dr in ds.Tables[7].Rows)
            {
                if (pos_Product.ProductID.ToString() == dr["ProductID"].ToString())
                {
                    pos_Product.Wastage_HO_Current = decimal.Parse(dr["Qty"].ToString());
                    pos_Product.Wastage_HO_Current_price = decimal.Parse(dr["QtyPrice"].ToString());
                    break;
                }
            }

            //Issue_Wash_HO_Stock
            foreach (DataRow dr in ds.Tables[8].Rows)
            {
                if (pos_Product.ProductID.ToString() == dr["ProductID"].ToString())
                {
                    pos_Product.Issue_Wash_HO_Stock = decimal.Parse(dr["Qty"].ToString());
                    pos_Product.Issue_Wash_HO_Stock_price = decimal.Parse(dr["QtyPrice"].ToString());
                    break;
                }
            }

            //Issue_Wash_HO_Current
            foreach (DataRow dr in ds.Tables[9].Rows)
            {
                if (pos_Product.ProductID.ToString() == dr["ProductID"].ToString())
                {
                    pos_Product.Issue_Wash_HO_Current = decimal.Parse(dr["Qty"].ToString());
                    pos_Product.Issue_Wash_HO_Current_price = decimal.Parse(dr["QtyPrice"].ToString());
                    break;
                }
            }

            //Back_After_Wash_Stock
            foreach (DataRow dr in ds.Tables[10].Rows)
            {
                if (pos_Product.ProductID.ToString() == dr["ProductID"].ToString())
                {
                    pos_Product.Back_After_Wash_Stock = decimal.Parse(dr["Qty"].ToString());
                    pos_Product.Back_After_Wash_Stock_price = decimal.Parse(dr["QtyPrice"].ToString());
                    break;
                }
            }

            //Back_After_Wash_Current
            foreach (DataRow dr in ds.Tables[11].Rows)
            {
                if (pos_Product.ProductID.ToString() == dr["ProductID"].ToString())
                {
                    pos_Product.Back_After_Wash_Current = decimal.Parse(dr["Qty"].ToString());
                    pos_Product.Back_After_Wash_Current_price = decimal.Parse(dr["QtyPrice"].ToString());
                    break;
                }
            }

            //Issue_for_Repair_Stock
            foreach (DataRow dr in ds.Tables[12].Rows)
            {
                if (pos_Product.ProductID.ToString() == dr["ProductID"].ToString())
                {
                    pos_Product.Issue_for_Repair_Stock = decimal.Parse(dr["Qty"].ToString());
                    pos_Product.Issue_for_Repair_Stock_price = decimal.Parse(dr["QtyPrice"].ToString());
                    break;
                }
            }

            //Issue_for_Repair_Current
            foreach (DataRow dr in ds.Tables[13].Rows)
            {
                if (pos_Product.ProductID.ToString() == dr["ProductID"].ToString())
                {
                    pos_Product.Issue_for_Repair_Current = decimal.Parse(dr["Qty"].ToString());
                    pos_Product.Issue_for_Repair_Current_price = decimal.Parse(dr["QtyPrice"].ToString());
                    break;
                }
            }

            //Back_after_repair_Stock
            foreach (DataRow dr in ds.Tables[14].Rows)
            {
                if (pos_Product.ProductID.ToString() == dr["ProductID"].ToString())
                {
                    pos_Product.Back_after_repair_Stock = decimal.Parse(dr["Qty"].ToString());
                    pos_Product.Back_after_repair_Stock_price = decimal.Parse(dr["QtyPrice"].ToString());
                    break;
                }
            }

            //Back_after_repair_Current
            foreach (DataRow dr in ds.Tables[15].Rows)
            {
                if (pos_Product.ProductID.ToString() == dr["ProductID"].ToString())
                {
                    pos_Product.Back_after_repair_Current = decimal.Parse(dr["Qty"].ToString());
                    pos_Product.Back_after_repair_Current_price = decimal.Parse(dr["QtyPrice"].ToString());
                    break;
                }
            }

            //Issue_to_Showroom_Stock
            foreach (DataRow dr in ds.Tables[16].Rows)
            {
                if (pos_Product.ProductID.ToString() == dr["ProductID"].ToString())
                {
                    pos_Product.Issue_to_Showroom_Stock = decimal.Parse(dr["Qty"].ToString());
                    pos_Product.Issue_to_Showroom_Stock_price = decimal.Parse(dr["QtyPrice"].ToString());
                    break;
                }
            }

            //Issue_to_Showroom_Current
            foreach (DataRow dr in ds.Tables[17].Rows)
            {
                if (pos_Product.ProductID.ToString() == dr["ProductID"].ToString())
                {
                    pos_Product.Issue_to_Showroom_Current = decimal.Parse(dr["Qty"].ToString());
                    pos_Product.Issue_to_Showroom_Current_price = decimal.Parse(dr["QtyPrice"].ToString());
                    break;
                }
            }

            //Issue_Return_HO_Stock
            foreach (DataRow dr in ds.Tables[18].Rows)
            {
                if (pos_Product.ProductID.ToString() == dr["ProductID"].ToString())
                {
                    pos_Product.Issue_Return_HO_Stock = decimal.Parse(dr["Qty"].ToString());
                    pos_Product.Issue_Return_HO_Stock_price = decimal.Parse(dr["QtyPrice"].ToString());
                    break;
                }
            }

            //Issue_Return_HO_Current
            foreach (DataRow dr in ds.Tables[19].Rows)
            {
                if (pos_Product.ProductID.ToString() == dr["ProductID"].ToString())
                {
                    pos_Product.Issue_Return_HO_Current = decimal.Parse(dr["Qty"].ToString());
                    pos_Product.Issue_Return_HO_Current_price = decimal.Parse(dr["QtyPrice"].ToString());
                    break;
                }
            }

            //Gift_HO_Stock
            foreach (DataRow dr in ds.Tables[20].Rows)
            {
                if (pos_Product.ProductID.ToString() == dr["ProductID"].ToString())
                {
                    pos_Product.Gift_HO_Stock = decimal.Parse(dr["Qty"].ToString());
                    pos_Product.Gift_HO_Stock_price = decimal.Parse(dr["QtyPrice"].ToString());
                    break;
                }
            }

            //Gift_HO_Current
            foreach (DataRow dr in ds.Tables[21].Rows)
            {
                if (pos_Product.ProductID.ToString() == dr["ProductID"].ToString())
                {
                    pos_Product.Gift_HO_Current = decimal.Parse(dr["Qty"].ToString());
                    pos_Product.Gift_HO_Current_price = decimal.Parse(dr["QtyPrice"].ToString());
                    break;
                }
            }

            //Adjustment_Add_Showroom_Stock
            //foreach (DataRow dr in ds.Tables[22].Rows)
            //{
            //    if (pos_Product.ProductID.ToString() == dr["ProductID"].ToString())
            //    {
            pos_Product.Adjustment_Add_Showroom_Stock = 0;//decimal.Parse(dr["Qty"].ToString());
            pos_Product.Adjustment_Add_Showroom_Stock_price = 0;//decimal.Parse(dr["QtyPrice"].ToString());
            //        break;
            //    }
            //}

            //Adjustment_Add_Showroom_Current
            //foreach (DataRow dr in ds.Tables[23].Rows)
            //{
            //    if (pos_Product.ProductID.ToString() == dr["ProductID"].ToString())
            //    {
                    pos_Product.Adjustment_Add_Showroom_Current = 0;// decimal.Parse(dr["Qty"].ToString());
                    pos_Product.Adjustment_Add_Showroom_Current_price = 0;//decimal.Parse(dr["QtyPrice"].ToString());
            //        break;
            //    }
            //}

            //Adjustment_Sub_Showroom_Stock
            //foreach (DataRow dr in ds.Tables[24].Rows)
            //{
            //    if (pos_Product.ProductID.ToString() == dr["ProductID"].ToString())
            //    {
                    pos_Product.Adjustment_Sub_Showroom_Stock = 0;//decimal.Parse(dr["Qty"].ToString());
                    pos_Product.Adjustment_Sub_Showroom_Stock_price = 0;//decimal.Parse(dr["QtyPrice"].ToString());
                    //break;
            //    }
            //}

            //Adjustment_Sub_Showroom_Current
            //foreach (DataRow dr in ds.Tables[25].Rows)
            //{
            //    if (pos_Product.ProductID.ToString() == dr["ProductID"].ToString())
            //    {
                    pos_Product.Adjustment_Sub_Showroom_Current = 0;//decimal.Parse(dr["Qty"].ToString());
                    pos_Product.Adjustment_Sub_Showroom_Current_price = 0;//decimal.Parse(dr["QtyPrice"].ToString());
                    //break;
            //    }
            //}

            //Purchase_Stock
            foreach (DataRow dr in ds.Tables[22].Rows)
            {
                if (pos_Product.ProductID.ToString() == dr["ProductID"].ToString())
                {
                    pos_Product.Purchase_Stock = decimal.Parse(dr["Qty"].ToString());
                    pos_Product.Purchase_Stock_price = decimal.Parse(dr["QtyPrice"].ToString());
                    break;
                }
            }

            //Purchase_Current
            foreach (DataRow dr in ds.Tables[23].Rows)
            {
                if (pos_Product.ProductID.ToString() == dr["ProductID"].ToString())
                {
                    pos_Product.Purchase_Current = decimal.Parse(dr["Qty"].ToString());
                    pos_Product.Purchase_Current_price = decimal.Parse(dr["QtyPrice"].ToString());
                    break;
                }
            }

            //PurchaseAdjustment_Stock
            foreach (DataRow dr in ds.Tables[24].Rows)
            {
                if (pos_Product.ProductID.ToString() == dr["ProductID"].ToString())
                {
                    pos_Product.PurchaseAdjustment_Stock = decimal.Parse(dr["Qty"].ToString());
                    pos_Product.PurchaseAdjustment_Stock_price = decimal.Parse(dr["QtyPrice"].ToString());
                    break;
                }
            }

            //PurchaseAdjustment_Current
            foreach (DataRow dr in ds.Tables[25].Rows)
            {
                if (pos_Product.ProductID.ToString() == dr["ProductID"].ToString())
                {
                    pos_Product.PurchaseAdjustment_Current = decimal.Parse(dr["Qty"].ToString());
                    pos_Product.PurchaseAdjustment_Current_price = decimal.Parse(dr["QtyPrice"].ToString());
                    break;
                }
            }

            //PurchaseReturn_Stock
            foreach (DataRow dr in ds.Tables[26].Rows)
            {
                if (pos_Product.ProductID.ToString() == dr["ProductID"].ToString())
                {
                    pos_Product.PurchaseReturn_Stock = decimal.Parse(dr["Qty"].ToString());
                    pos_Product.PurchaseReturn_Stock_price = decimal.Parse(dr["QtyPrice"].ToString());
                    break;
                }
            }

            //PurchaseReturn_Current
            foreach (DataRow dr in ds.Tables[27].Rows)
            {
                if (pos_Product.ProductID.ToString() == dr["ProductID"].ToString())
                {
                    pos_Product.PurchaseReturn_Current = decimal.Parse(dr["Qty"].ToString());
                    pos_Product.PurchaseReturn_Current_price = decimal.Parse(dr["QtyPrice"].ToString());
                    break;
                }
            }

            /*
                Production
                Production Adjustment
                Lost in HO
                Wastage in HO
                Issue for Wash from HO
                Back after wash
                Issue for Repair
                Back after repair
                Issue to Showroom
                Issue Return to HO
                Gift in HO
                Adjustment(+) in Showroom
                Adjustment(-) in Showroom
                Purchase
                Purchase Adjustment
                Purchase Return

             */
            //Opining Stock
            pos_Product.OpiningStock =
                pos_Product.Production_Stock
                +
                pos_Product.ProductionAdjustment_Stock
                -
                pos_Product.Lost_HO_Stock
                -
                pos_Product.Wastage_HO_Stock
                -
                pos_Product.Issue_Wash_HO_Stock
                +
                pos_Product.Back_After_Wash_Stock
                -
                pos_Product.Issue_for_Repair_Stock
                +
                pos_Product.Back_after_repair_Stock
                -
                pos_Product.Issue_to_Showroom_Stock
                +
                pos_Product.Issue_Return_HO_Stock
                -
                pos_Product.Gift_HO_Stock
                -
                (0*pos_Product.Adjustment_Add_Showroom_Stock)
                +
                (0 * pos_Product.Adjustment_Sub_Showroom_Stock)
                +
                pos_Product.Purchase_Stock
                +
                pos_Product.PurchaseAdjustment_Stock
                -
                pos_Product.PurchaseReturn_Stock;

            //Stock in hand
            pos_Product.StockInHand =
                pos_Product.OpiningStock
                +
                pos_Product.Production_Current
                +
                pos_Product.ProductionAdjustment_Current
                -
                pos_Product.Lost_HO_Current
                -
                pos_Product.Wastage_HO_Current
                -
                pos_Product.Issue_Wash_HO_Current
                +
                pos_Product.Back_After_Wash_Current
                -
                pos_Product.Issue_for_Repair_Current
                +
                pos_Product.Back_after_repair_Current
                -
                pos_Product.Issue_to_Showroom_Current
                +
                pos_Product.Issue_Return_HO_Current
                -
                pos_Product.Gift_HO_Current
                -
                (0*pos_Product.Adjustment_Add_Showroom_Current)
                +
                (0*pos_Product.Adjustment_Sub_Showroom_Current)
                +
                pos_Product.Purchase_Current
                +
                pos_Product.PurchaseAdjustment_Current
                -
                pos_Product.PurchaseReturn_Current;

            //Opining Stock price
            pos_Product.OpiningStockPrice =
                pos_Product.Production_Stock_price
                +
                pos_Product.ProductionAdjustment_Stock_price
                -
                pos_Product.Lost_HO_Stock_price
                -
                pos_Product.Wastage_HO_Stock_price
                -
                pos_Product.Issue_Wash_HO_Stock_price
                +
                pos_Product.Back_After_Wash_Stock_price
                -
                pos_Product.Issue_for_Repair_Stock_price
                +
                pos_Product.Back_after_repair_Stock_price
                -
                pos_Product.Issue_to_Showroom_Stock_price
                +
                pos_Product.Issue_Return_HO_Stock_price
                -
                pos_Product.Gift_HO_Stock_price
                -
                (0*pos_Product.Adjustment_Add_Showroom_Stock_price )
                +
                (0*pos_Product.Adjustment_Sub_Showroom_Stock_price )
                +
                pos_Product.Purchase_Stock_price
                +
                pos_Product.PurchaseAdjustment_Stock_price
                -
                pos_Product.PurchaseReturn_Stock_price ;

            //Stock in hand
            pos_Product.StockInHandPrice =
                pos_Product.OpiningStockPrice
                +
                pos_Product.Production_Current_price
                +
                pos_Product.ProductionAdjustment_Current_price
                -
                pos_Product.Lost_HO_Current_price
                -
                pos_Product.Wastage_HO_Current_price
                -
                pos_Product.Issue_Wash_HO_Current_price
                +
                pos_Product.Back_After_Wash_Current_price
                -
                pos_Product.Issue_for_Repair_Current_price
                +
                pos_Product.Back_after_repair_Current_price
                -
                pos_Product.Issue_to_Showroom_Current_price
                +
                pos_Product.Issue_Return_HO_Current_price
                -
                pos_Product.Gift_HO_Current_price
                -
                (0*pos_Product.Adjustment_Add_Showroom_Current_price )
                +
                (0* pos_Product.Adjustment_Sub_Showroom_Current_price )
                +
                pos_Product.Purchase_Current_price
                +
                pos_Product.PurchaseAdjustment_Current_price
                -
                pos_Product.PurchaseReturn_Current_price ;

        }

        decimal t_opining = 0;
        decimal t_opiningPrice = 0;
        decimal t_StockInhand = 0;
        decimal t_StockInhandPrice = 0;

        decimal t_Production_Current_price = 0;
        decimal t_ProductionAdjustment_Current_price = 0;
        decimal t_Purchase_Current_price = 0;
        decimal t_PurchaseAdjustment_Current_price = 0;
        decimal t_PurchaseReturn_Current_price = 0;
        decimal t_Lost_HO_Current_price = 0;
        decimal t_Wastage_HO_Current_price = 0;
        decimal t_Issue_Wash_HO_Current_price = 0;
        decimal t_Back_After_Wash_Current_price = 0;
        decimal t_Issue_for_Repair_Current_price = 0;
        decimal t_Back_after_repair_Current_price = 0;
        decimal t_Issue_to_Showroom_Current_price = 0;
        decimal t_Issue_Return_HO_Current_price = 0;
        decimal t_Send_another_Showroom_Current_price = 0;
        decimal t_Received_another_Showroom_Current_price = 0;
        decimal t_Sales_Current_price = 0;
        decimal t_Sales_return_Current_price = 0;
        decimal t_Gift_HO_Current_price = 0;
        decimal t_Gift_Showroom_Current_price = 0;
        decimal t_Send_wash_Showroom_Current_price = 0;
        decimal t_Received_wash_Showroom_Current_price = 0;
        decimal t_Send_repair_Showroom_Current_price = 0;
        decimal t_Received_repair_Showroom_Current_price = 0;
        decimal t_Lost_Showroom_Current_price = 0;
        decimal t_Wastage_Showroom_Current_price = 0;
        decimal t_Adjustment_Add_Showroom_Current_price = 0;
        decimal t_Adjustment_Sub_Showroom_Current_price = 0;

         decimal t_Production_Current = 0;
        decimal t_ProductionAdjustment_Current = 0;
        decimal t_Purchase_Current = 0;
        decimal t_PurchaseAdjustment_Current = 0;
        decimal t_PurchaseReturn_Current = 0;
        decimal t_Lost_HO_Current = 0;
        decimal t_Wastage_HO_Current = 0;
        decimal t_Issue_Wash_HO_Current = 0;
        decimal t_Back_After_Wash_Current = 0;
        decimal t_Issue_for_Repair_Current = 0;
        decimal t_Back_after_repair_Current = 0;
        decimal t_Issue_to_Showroom_Current = 0;
        decimal t_Issue_Return_HO_Current = 0;
        decimal t_Send_another_Showroom_Current = 0;
        decimal t_Received_another_Showroom_Current = 0;
        decimal t_Sales_Current = 0;
        decimal t_Sales_return_Current = 0;
        decimal t_Gift_HO_Current = 0;
        decimal t_Gift_Showroom_Current = 0;
        decimal t_Send_wash_Showroom_Current = 0;
        decimal t_Received_wash_Showroom_Current = 0;
        decimal t_Send_repair_Showroom_Current = 0;
        decimal t_Received_repair_Showroom_Current = 0;
        decimal t_Lost_Showroom_Current = 0;
        decimal t_Wastage_Showroom_Current = 0;
        decimal t_Adjustment_Add_Showroom_Current = 0;
        decimal t_Adjustment_Sub_Showroom_Current = 0;

        int serialNo = 1;

        string htmlTable = @" <table id='itemList_tbl' style='border:1px solid black;width:100%;' cellpadding='0' cellspacing='0'>
                        <tr id='tableHeader'>
                            <td  style='border-left:0px;'>S/L</td>
                            <td>Product Code</td>
                            <td>Product Name</td>
                            <td style='display:none;'>Unit</td>
                            <td>Opining<br>(Qty)</td>
                            <td style='display:none;'>Opining<br>(Price)</td>
                            ";
            foreach (Pos_TransactionType type in allTransactionType)
            {
                try
                {
                    if (int.Parse(type.CentralStockFormula) != 0)
                    {
                        if (type.ExtraField3.Split('-')[0] == "1")
                        {
                            htmlTable += @"<td>" + type.TransactionTypeName.Replace(" ", "<br/>") + "<br>(Qty)" + "</td>";
                            htmlTable += @"<td style='display:none;'>" + type.TransactionTypeName.Replace(" ", "<br/>") + "<br>(Price)" + "</td>";
                        }
                    }
                }
                catch(Exception ex)
                { }
            }

            htmlTable += @"<td>Stock<br/>Quantity</td>
                            <td>Stock<br/>Amount</td>
                        </tr>";
            foreach (Pos_Product pos_Product in Products)
            {
                //if (pos_Product.PurchasedQuantity == 0
                //    && pos_Product.PurchasedQuantityPrice == 0 &&
                //    pos_Product.ExtraField2 == "0"&&
                //    pos_Product.ExtraField4== "0"&&
                //    pos_Product.ExtraField6 == "0"&&
                //    pos_Product.ExtraField8 == "0"&&
                //    pos_Product.ExtraField10 == "0"&&
                //    pos_Product.ExtraFieldQuantity2==0 &&
                //    pos_Product.ExtraFieldQuantity4==0
                //    )
                //{
                //    continue;
                //}

                htmlTable += @"<tr  class='itemCss'>
                            <td  style='border-left:0px;'>" + (serialNo++).ToString() + @"</td>
                            <td>" +pos_Product.BarCode + @"</td>
                            <td>" + pos_Product.ProductName + @"</td>
                            <td  style='display:none;'>" + pos_Product.Inv_QuantityUniteName + @"</td>
                            <td style='text-align:right;'>" + pos_Product.OpiningStock.ToString("0,0.00") + @"</td>
                            <td style='text-align:right;display:none;'>" + pos_Product.OpiningStockPrice.ToString("0,0.00") + @"</td>";

                htmlTable += @"<td style='text-align:right;'>" + pos_Product.Production_Current.ToString("0,0.00") + "</td>";
                htmlTable += @"<td style='text-align:right;display:none;'>" + pos_Product.Production_Current_price.ToString("0,0.00") + "</td>";
                htmlTable += @"<td style='text-align:right;'>" + pos_Product.Purchase_Current.ToString("0,0.00") + "</td>";
                htmlTable += @"<td style='text-align:right;display:none;'>" + pos_Product.Purchase_Current_price.ToString("0,0.00") + "</td>";
                //htmlTable += @"<td style='text-align:right;'>" + pos_Product.PurchaseAdjustment_Current.ToString("0,0.00") + "</td>";
                //htmlTable += @"<td style='text-align:right;display:none;'>" + pos_Product.PurchaseAdjustment_Current_price.ToString("0,0.00") + "</td>";
                htmlTable += @"<td style='text-align:right;'>" + pos_Product.PurchaseReturn_Current.ToString("0,0.00") + "</td>";
                htmlTable += @"<td style='text-align:right;display:none;'>" + pos_Product.PurchaseReturn_Current_price.ToString("0,0.00") + "</td>";
                //htmlTable += @"<td style='text-align:right;'>" +pos_Product.ProductionAdjustment_Current+"</td>";
                //htmlTable += @"<td style='text-align:right;'>" +pos_Product.Lost_HO_Current+"</td>";
                //htmlTable += @"<td style='text-align:right;'>" + pos_Product.Wastage_HO_Current.ToString("0,0.00") + "</td>";
                //htmlTable += @"<td style='text-align:right;'>" + pos_Product.Issue_for_Repair_Current.ToString("0,0.00") + "</td>";
                //htmlTable += @"<td style='text-align:right;display:none;'>" + pos_Product.Issue_for_Repair_Current_price.ToString("0,0.00") + "</td>";
                //htmlTable += @"<td style='text-align:right;'>" + pos_Product.Back_after_repair_Current.ToString("0,0.00") + "</td>";
                //htmlTable += @"<td style='text-align:right;display:none;'>" + pos_Product.Back_after_repair_Current_price.ToString("0,0.00") + "</td>";
                htmlTable += @"<td style='text-align:right;'>" + pos_Product.Issue_to_Showroom_Current.ToString("0,0.00") + "</td>";
                htmlTable += @"<td style='text-align:right;display:none;'>" + pos_Product.Issue_to_Showroom_Current_price.ToString("0,0.00") + "</td>";
                htmlTable += @"<td style='text-align:right;'>" + pos_Product.Issue_Return_HO_Current.ToString("0,0.00") + "</td>";
                htmlTable += @"<td style='text-align:right;display:none;'>" + pos_Product.Issue_Return_HO_Current_price.ToString("0,0.00") + "</td>";
                htmlTable += @"<td style='text-align:right;'>" + pos_Product.Gift_HO_Current.ToString("0,0.00") + "</td>";
                htmlTable += @"<td style='text-align:right;display:none;'>" + pos_Product.Gift_HO_Current_price.ToString("0,0.00") + "</td>";
                //htmlTable += @"<td style='text-align:right;'>" +pos_Product.Adjustment_Add_Showroom_Current+"</td>";
                //htmlTable += @"<td style='text-align:right;'>" +pos_Product.Adjustment_Sub_Showroom_Current+"</td>";
                htmlTable += @"<td style='text-align:right;'>" + pos_Product.Back_After_Wash_Current.ToString("0,0.00") + "</td>";
                htmlTable += @"<td style='text-align:right;'>" + pos_Product.Issue_Wash_HO_Current.ToString("0,0.00") + "</td>";

                htmlTable += @"<td style='text-align:right;'>" + pos_Product.StockInHand.ToString("0,0.00") + @"</td>
                            <td style='text-align:right;'>" + pos_Product.StockInHandPrice.ToString("0,0.00") + @"</td>
                        </tr>";

                t_opining += pos_Product.OpiningStock;
                t_opiningPrice += pos_Product.OpiningStockPrice;
                t_StockInhand += pos_Product.StockInHand;
                t_StockInhandPrice += pos_Product.StockInHandPrice;

                t_Production_Current+= pos_Product.Production_Current ;
                t_ProductionAdjustment_Current +=pos_Product.ProductionAdjustment_Current ;
                t_Lost_HO_Current +=pos_Product.Lost_HO_Current ;
                t_Wastage_HO_Current +=pos_Product.Wastage_HO_Current ;
                t_Issue_Wash_HO_Current +=pos_Product.Issue_Wash_HO_Current ;
                t_Back_After_Wash_Current +=pos_Product.Back_After_Wash_Current ;
                t_Issue_for_Repair_Current += pos_Product.Issue_for_Repair_Current;
                t_Back_after_repair_Current += pos_Product.Back_after_repair_Current;
                t_Issue_to_Showroom_Current += pos_Product.Issue_to_Showroom_Current;
                t_Issue_Return_HO_Current += pos_Product.Issue_Return_HO_Current;
                t_Gift_HO_Current += pos_Product.Gift_HO_Current;
                t_Adjustment_Add_Showroom_Current += pos_Product.Adjustment_Add_Showroom_Current;
                t_Adjustment_Sub_Showroom_Current += pos_Product.Adjustment_Sub_Showroom_Current;
                t_Purchase_Current += pos_Product.Purchase_Current;
                t_PurchaseAdjustment_Current += pos_Product.PurchaseAdjustment_Current;
                t_PurchaseReturn_Current += pos_Product.PurchaseReturn_Current;

                t_Production_Current_price += pos_Product.Production_Current_price;
                t_ProductionAdjustment_Current_price += pos_Product.ProductionAdjustment_Current_price;
                t_Lost_HO_Current_price += pos_Product.Lost_HO_Current_price;
                t_Wastage_HO_Current_price += pos_Product.Wastage_HO_Current_price;
                t_Issue_Wash_HO_Current_price += pos_Product.Issue_Wash_HO_Current_price;
                t_Back_After_Wash_Current_price += pos_Product.Back_After_Wash_Current_price;
                t_Issue_for_Repair_Current_price += pos_Product.Issue_for_Repair_Current_price;
                t_Back_after_repair_Current_price += pos_Product.Back_after_repair_Current_price;
                t_Issue_to_Showroom_Current_price += pos_Product.Issue_to_Showroom_Current_price;
                t_Issue_Return_HO_Current_price += pos_Product.Issue_Return_HO_Current_price;
                t_Gift_HO_Current_price += pos_Product.Gift_HO_Current_price;
                t_Adjustment_Add_Showroom_Current_price += pos_Product.Adjustment_Add_Showroom_Current_price;
                t_Adjustment_Sub_Showroom_Current_price += pos_Product.Adjustment_Sub_Showroom_Current_price;
                t_Purchase_Current_price += pos_Product.Purchase_Current_price;
                t_PurchaseAdjustment_Current_price += pos_Product.PurchaseAdjustment_Current_price;
                t_PurchaseReturn_Current_price += pos_Product.PurchaseReturn_Current_price;
            }

            htmlTable += @"<tr class='subtotalRow'>
                            <td>&nbsp;</td>
                            <td style='display:none;'>&nbsp;</td>
                            <td>&nbsp;</td>
                            <td>Total Qty</td>
                            <td style='text-align:right;'>" + t_opining.ToString("0,0.00") + @"</td>
                            <td style='text-align:right;display:none;'>" + t_opiningPrice.ToString("0,0.00") + @"</td>";

            htmlTable += @"<td style='text-align:right;'>" + t_Production_Current.ToString("0,0.00") + "</td>";// pos_Product.Production_Current;
            htmlTable += @"<td style='text-align:right;display:none;'>" + t_Production_Current_price.ToString("0,0.00") + "</td>";// pos_Product.Production_Current;
            htmlTable += @"<td style='text-align:right;'>" + t_Purchase_Current.ToString("0,0.00") + "</td>";// pos_Product.Purchase_Current;
            htmlTable += @"<td style='text-align:right;display:none;'>" + t_Purchase_Current_price.ToString("0,0.00") + "</td>";// pos_Product.Purchase_Current;
            //htmlTable += @"<td style='text-align:right;'>" + t_PurchaseAdjustment_Current.ToString("0,0.00") + "</td>";// pos_Product.PurchaseAdjustment_Current;
            //htmlTable += @"<td style='text-align:right;display:none;'>" + t_PurchaseAdjustment_Current_price.ToString("0,0.00") + "</td>";// pos_Product.PurchaseAdjustment_Current;
            htmlTable += @"<td style='text-align:right;'>" + t_PurchaseReturn_Current.ToString("0,0.00") + "</td>";// pos_Product.PurchaseReturn_Current;
            htmlTable += @"<td style='text-align:right;display:none;'>" + t_PurchaseReturn_Current_price.ToString("0,0.00") + "</td>";// pos_Product.PurchaseReturn_Current;
            //htmlTable += @"<td style='text-align:right;'>" +t_ProductionAdjustment_Current.ToString("0,0.00") + "</td>";// pos_Product.ProductionAdjustment_Current;
            //htmlTable += @"<td style='text-align:right;'>" +t_Lost_HO_Current.ToString("0,0.00") + "</td>";// pos_Product.Lost_HO_Current;
            //htmlTable += @"<td style='text-align:right;'>" + t_Wastage_HO_Current.ToString("0,0.00") + "</td>";// pos_Product.Wastage_HO_Current;
            //htmlTable += @"<td style='text-align:right;'>" + t_Issue_for_Repair_Current.ToString("0,0.00") + "</td>";// pos_Product.Issue_for_Repair_Current;
            //htmlTable += @"<td style='text-align:right;display:none;'>" + t_Issue_for_Repair_Current_price.ToString("0,0.00") + "</td>";// pos_Product.Issue_for_Repair_Current;
            //htmlTable += @"<td style='text-align:right;'>" + t_Back_after_repair_Current.ToString("0,0.00") + "</td>";// pos_Product.Back_after_repair_Current;
            //htmlTable += @"<td style='text-align:right;display:none;'>" + t_Back_after_repair_Current_price.ToString("0,0.00") + "</td>";// pos_Product.Back_after_repair_Current;
            htmlTable += @"<td style='text-align:right;'>" + t_Issue_to_Showroom_Current.ToString("0,0.00") + "</td>";// pos_Product.Issue_to_Showroom_Current;
            htmlTable += @"<td style='text-align:right;display:none;'>" + t_Issue_to_Showroom_Current_price.ToString("0,0.00") + "</td>";// pos_Product.Issue_to_Showroom_Current;
            htmlTable += @"<td style='text-align:right;'>" + t_Issue_Return_HO_Current.ToString("0,0.00") + "</td>";// pos_Product.Issue_Return_HO_Current;
            htmlTable += @"<td style='text-align:right;display:none;'>" + t_Issue_Return_HO_Current_price.ToString("0,0.00") + "</td>";// pos_Product.Issue_Return_HO_Current;
            htmlTable += @"<td style='text-align:right;'>" + t_Gift_HO_Current.ToString("0,0.00") + "</td>";// pos_Product.Gift_HO_Current;
            htmlTable += @"<td style='text-align:right;display:none;'>" + t_Gift_HO_Current_price.ToString("0,0.00") + "</td>";// pos_Product.Gift_HO_Current;
            //htmlTable += @"<td style='text-align:right;'>" + t_Adjustment_Add_Showroom_Current.ToString("0,0.00") + "</td>";// pos_Product.Adjustment_Add_Showroom_Current;
            //htmlTable += @"<td style='text-align:right;'>" + t_Adjustment_Sub_Showroom_Current.ToString("0,0.00") + "</td>";// pos_Product.Adjustment_Sub_Showroom_Current;
            htmlTable += @"<td style='text-align:right;'>" + t_Back_After_Wash_Current.ToString("0,0.00") + "</td>";// pos_Product.Back_After_Wash_Current;
            htmlTable += @"<td style='text-align:right;'>" + t_Issue_Wash_HO_Current.ToString("0,0.00") + "</td>";// pos_Product.Issue_Wash_HO_Current;

            htmlTable += @"<td style='text-align:right;'>" + t_StockInhand.ToString("0,0.00") + @"</td>
                            <td style='text-align:right;'>" + t_StockInhandPrice.ToString("0,0.00") + @"</td>
                        </tr>";

            htmlTable += @"<tr class='subtotalRow'>
                            <td>&nbsp;</td>
                            <td style='display:none;'>&nbsp;</td>
                            <td>&nbsp;</td>
                            <td>Total Price</td>
                            <td style='text-align:right;display:none;'>" + t_opining.ToString("0,0.00") + @"</td>
                            <td style='text-align:right;'>" + t_opiningPrice.ToString("0,0.00") + @"</td>";

            htmlTable += @"<td style='text-align:right;display:none;'>" + t_Production_Current.ToString("0,0.00") + "</td>";// pos_Product.Production_Current;
            htmlTable += @"<td style='text-align:right;'>" + t_Production_Current_price.ToString("0,0.00") + "</td>";// pos_Product.Production_Current;
            htmlTable += @"<td style='text-align:right;display:none;'>" + t_Purchase_Current.ToString("0,0.00") + "</td>";// pos_Product.Purchase_Current;
            htmlTable += @"<td style='text-align:right;'>" + t_Purchase_Current_price.ToString("0,0.00") + "</td>";// pos_Product.Purchase_Current;
            //htmlTable += @"<td style='text-align:right;display:none;'>" + t_PurchaseAdjustment_Current.ToString("0,0.00") + "</td>";// pos_Product.PurchaseAdjustment_Current;
            //htmlTable += @"<td style='text-align:right;'>" + t_PurchaseAdjustment_Current_price.ToString("0,0.00") + "</td>";// pos_Product.PurchaseAdjustment_Current;
            htmlTable += @"<td style='text-align:right;display:none;'>" + t_PurchaseReturn_Current.ToString("0,0.00") + "</td>";// pos_Product.PurchaseReturn_Current;
            htmlTable += @"<td style='text-align:right;'>" + t_PurchaseReturn_Current_price.ToString("0,0.00") + "</td>";// pos_Product.PurchaseReturn_Current;
            //htmlTable += @"<td style='text-align:right;'>" +t_ProductionAdjustment_Current.ToString("0,0.00") + "</td>";// pos_Product.ProductionAdjustment_Current;
            //htmlTable += @"<td style='text-align:right;'>" +t_Lost_HO_Current.ToString("0,0.00") + "</td>";// pos_Product.Lost_HO_Current;
            //htmlTable += @"<td style='text-align:right;'>" +t_Wastage_HO_Current.ToString("0,0.00") + "</td>";// pos_Product.Wastage_HO_Current;
            //htmlTable += @"<td style='text-align:right;display:none;'>" + t_Issue_for_Repair_Current.ToString("0,0.00") + "</td>";// pos_Product.Issue_for_Repair_Current;
            //htmlTable += @"<td style='text-align:right;'>" + t_Issue_for_Repair_Current_price.ToString("0,0.00") + "</td>";// pos_Product.Issue_for_Repair_Current;
            //htmlTable += @"<td style='text-align:right;display:none;'>" + t_Back_after_repair_Current.ToString("0,0.00") + "</td>";// pos_Product.Back_after_repair_Current;
            //htmlTable += @"<td style='text-align:right;'>" + t_Back_after_repair_Current_price.ToString("0,0.00") + "</td>";// pos_Product.Back_after_repair_Current;
            htmlTable += @"<td style='text-align:right;display:none;'>" + t_Issue_to_Showroom_Current.ToString("0,0.00") + "</td>";// pos_Product.Issue_to_Showroom_Current;
            htmlTable += @"<td style='text-align:right;'>" + t_Issue_to_Showroom_Current_price.ToString("0,0.00") + "</td>";// pos_Product.Issue_to_Showroom_Current;
            htmlTable += @"<td style='text-align:right;display:none;'>" + t_Issue_Return_HO_Current.ToString("0,0.00") + "</td>";// pos_Product.Issue_Return_HO_Current;
            htmlTable += @"<td style='text-align:right;'>" + t_Issue_Return_HO_Current_price.ToString("0,0.00") + "</td>";// pos_Product.Issue_Return_HO_Current;
            htmlTable += @"<td style='text-align:right;display:none;'>" + t_Gift_HO_Current.ToString("0,0.00") + "</td>";// pos_Product.Gift_HO_Current;
            htmlTable += @"<td style='text-align:right;'>" + t_Gift_HO_Current_price.ToString("0,0.00") + "</td>";// pos_Product.Gift_HO_Current;
            //htmlTable += @"<td style='text-align:right;'>" + t_Adjustment_Add_Showroom_Current.ToString("0,0.00") + "</td>";// pos_Product.Adjustment_Add_Showroom_Current;
            //htmlTable += @"<td style='text-align:right;'>" + t_Adjustment_Sub_Showroom_Current.ToString("0,0.00") + "</td>";// pos_Product.Adjustment_Sub_Showroom_Current;
            htmlTable += @"<td style='text-align:right;'>" + t_Back_After_Wash_Current_price.ToString("0,0.00") + "</td>";// pos_Product.Back_After_Wash_Current;
            htmlTable += @"<td style='text-align:right;'>" + t_Issue_Wash_HO_Current_price.ToString("0,0.00") + "</td>";// pos_Product.Issue_Wash_HO_Current;

            htmlTable += @"<td style='text-align:right;'>" + t_StockInhand.ToString("0,0.00") + @"</td>
                            <td style='text-align:right;'>" + t_StockInhandPrice.ToString("0,0.00") + @"</td>
                        </tr></table>";

            lblItemList.Text = htmlTable;
    }
예제 #9
0
    public static int InsertPos_Product(Pos_Product pos_Product)
    {
        SqlPos_ProductProvider sqlPos_ProductProvider = new SqlPos_ProductProvider();

        return(sqlPos_ProductProvider.InsertPos_Product(pos_Product));
    }
예제 #10
0
 public static bool UpdatePos_Product(Pos_Product pos_Product)
 {
     SqlPos_ProductProvider sqlPos_ProductProvider = new SqlPos_ProductProvider();
     return sqlPos_ProductProvider.UpdatePos_Product(pos_Product);
 }
예제 #11
0
파일: Sales.aspx.cs 프로젝트: anam/gp-HO
    protected void lbDeletePayment_Click(object sender, EventArgs e)
    {
        LinkButton linkButton = new LinkButton();
        linkButton = (LinkButton)sender;
        int id= Convert.ToInt32(linkButton.CommandArgument);

        List<Pos_Product> paymentList = new List<Pos_Product>();
        foreach (GridViewRow gvr in gvPayment.Rows)
        {
            HiddenField hfSerial = (HiddenField)gvr.FindControl("hfSerial");
            HiddenField hfIssueFromID = (HiddenField)gvr.FindControl("hfIssueFromID");
            Label lblCardNo = (Label)gvr.FindControl("lblCardNo");
            Label lblCardType = (Label)gvr.FindControl("lblCardType");
            Label lblIssueFrom = (Label)gvr.FindControl("lblIssueFrom");
            Label lblAmount = (Label)gvr.FindControl("lblAmount");

            Pos_Product PaymentGrid = new Pos_Product();
            PaymentGrid.Pos_ProductID = int.Parse(hfSerial.Value);
            PaymentGrid.ExtraField1 = lblCardNo.Text;
            PaymentGrid.ExtraField2 = lblCardType.Text;
            PaymentGrid.ExtraField3 = lblIssueFrom.Text;
            PaymentGrid.ExtraField4 = hfIssueFromID.Value;
            PaymentGrid.ExtraField5 = lblAmount.Text;

            paymentList.Add(PaymentGrid);
        }

        int deleted_i = -1;
        for (int i = 0; i < paymentList.Count; i++)
        {
            if (id == paymentList[i].Pos_ProductID)
            {
                deleted_i = i;
                break;
            }
        }
        if (deleted_i != -1)
        {
            paymentList.Remove(paymentList[deleted_i]);
        }

        gvPayment.DataSource = paymentList;
        gvPayment.DataBind();

        decimal totalAmount = 0;
        foreach (GridViewRow gvr in gvPayment.Rows)
        {
            Label lblAmount = (Label)gvr.FindControl("lblAmount");
            totalAmount += decimal.Parse(lblAmount.Text);
        }

        txtCardAmount.Text = totalAmount.ToString("0,0.00");
        ((Label)gvPayment.FooterRow.FindControl("lblTotalCardAmountFooter")).Text = totalAmount.ToString("0,0.00");

        txtCashAmount_TextChanged(this, new EventArgs());
    }
예제 #12
0
    public static bool UpdatePos_Product(Pos_Product pos_Product)
    {
        SqlPos_ProductProvider sqlPos_ProductProvider = new SqlPos_ProductProvider();

        return(sqlPos_ProductProvider.UpdatePos_Product(pos_Product));
    }
예제 #13
0
 public static int InsertPos_Product(Pos_Product pos_Product)
 {
     SqlPos_ProductProvider sqlPos_ProductProvider = new SqlPos_ProductProvider();
     return sqlPos_ProductProvider.InsertPos_Product(pos_Product);
 }
예제 #14
0
 public Pos_Product GetPos_ProductFromReader(IDataReader reader)
 {
     try
     {
         Pos_Product pos_Product = new Pos_Product
             (
                 (int)reader["Pos_ProductID"],
                 (int)reader["ProductID"],
                 (int)reader["ReferenceID"],
                 (int)reader["Pos_ProductTypeID"],
                 reader["Inv_UtilizationDetailsIDs"].ToString(),
                 (int)reader["ProductStatusID"],
                 reader["ProductName"].ToString(),
                 reader["DesignCode"].ToString(),
                 (int)reader["Pos_SizeID"],
                 (int)reader["Pos_BrandID"],
                 (int)reader["Inv_QuantityUnitID"],
                 (decimal)reader["FabricsCost"],
                 (decimal)reader["AccesoriesCost"],
                 (decimal)reader["Overhead"],
                 (decimal)reader["OthersCost"],
                 (decimal)reader["PurchasePrice"],
                 (decimal)reader["SalePrice"],
                 (decimal)reader["OldSalePrice"],
                 reader["Note"].ToString(),
                 reader["BarCode"].ToString(),
                 (int)reader["Pos_ColorID"],
                 (int)reader["Pos_FabricsTypeID"],
                 reader["StyleCode"].ToString(),
                 reader["Pic1"].ToString(),
                 reader["Pic2"].ToString(),
                 reader["Pic3"].ToString(),
                 (decimal)reader["VatPercentage"],
                 (bool)reader["IsVatExclusive"],
                 (decimal)reader["DiscountPercentage"],
                 (decimal)reader["DiscountAmount"],
                 reader["FabricsNo"].ToString(),
                 reader["ExtraField1"].ToString(),
                 reader["ExtraField2"].ToString(),
                 reader["ExtraField3"].ToString(),
                 reader["ExtraField4"].ToString(),
                 reader["ExtraField5"].ToString(),
                 reader["ExtraField6"].ToString(),
                 reader["ExtraField7"].ToString(),
                 reader["ExtraField8"].ToString(),
                 reader["ExtraField9"].ToString(),
                 reader["ExtraField10"].ToString(),
                 (int)reader["AddedBy"],
                 (DateTime)reader["AddedDate"],
                 (int)reader["UpdatedBy"],
                 (DateTime)reader["UpdatedDate"],
                 (int)reader["RowStatusID"]
             );
          return pos_Product;
     }
     catch(Exception ex)
     {
         return null;
     }
 }
예제 #15
0
    protected void btnPurchaseProcess_Click(object sender, EventArgs e)
    {
        if (ddlSuppier.SelectedValue == "0" && Request.QueryString["IsReGenerateBarcode"]==null)
        {
            showAlartMessage("Select the supplier");
            return;
        }

        if (ddlProduct.SelectedValue != "0")
        {

            List<Pos_Product> configuringProdut = new List<Pos_Product>();
            bool anySizeSelected = false;
            foreach (DataListItem gvr in dlSize.Items)
            {
                CheckBox chkSelect = (CheckBox)gvr.FindControl("chkSelect");

                if (chkSelect.Checked)
                {
                    anySizeSelected = true;
                    Pos_Product prod = new Pos_Product();
                    prod.Pos_SizeID = int.Parse(chkSelect.ToolTip);
                    prod.ExtraField2 = chkSelect.Text;
                    prod.Inv_UtilizationDetailsIDs = "";
                    prod.ExtraField3 = "0";
                    prod.FabricsCost = 0;
                    prod.AccesoriesCost = 0;
                    prod.Overhead = 0;
                    prod.OthersCost = 0;
                    configuringProdut.Add(prod);
                }
            }

            if (!anySizeSelected)
            {
                showAlartMessage("Please select the size");
                return;
            }

            string sizeIDs = "";
            foreach (Pos_Product prod in configuringProdut)
            {
                if (sizeIDs != "") sizeIDs += ",";
                sizeIDs += prod.Pos_SizeID.ToString();
            }

            string sql = "Select ExtraField1,ExtraField2 from ACC_ChartOfAccountLabel4 where ACC_ChartOfAccountLabel4ID=" + ddlProduct.SelectedValue + ";";
            sql += @"SELECT [Pos_SizeID]
                          ,[SizeName]
                          ,[Code]
                      FROM [Pos_Size]
                      where Pos_SizeID in (" + sizeIDs + ");";

            DataSet ds = CommonManager.SQLExec(sql);

            foreach (Pos_Product prod in configuringProdut)
            {
                prod.DesignCode = decimal.Parse((ds.Tables[0].Rows[0]["ExtraField2"].ToString() == "" ? "1" : ds.Tables[0].Rows[0]["ExtraField2"].ToString())).ToString("00000");
                txtDesignCode.Text = prod.DesignCode;
                prod.ExtraField4 = ds.Tables[0].Rows[0]["ExtraField1"].ToString();
                foreach (DataRow dr in ds.Tables[1].Rows)
                {
                    if (prod.Pos_SizeID.ToString() == dr["Pos_SizeID"].ToString())
                    {
                        prod.ExtraField5 = dr["Code"].ToString();
                    }
                }
                prod.BarCode = prod.ExtraField4 + prod.DesignCode + prod.ExtraField5;
            }

            gvProductConfiguration.DataSource = configuringProdut;
            gvProductConfiguration.DataBind();

            foreach (GridViewRow gvr in gvProductConfiguration.Rows)
            {
                DropDownList ddlColor_Config = (DropDownList)gvr.FindControl("ddlColor_Config");
                DropDownList ddlPos_FabricsType = (DropDownList)gvr.FindControl("ddlPos_FabricsType");
                HiddenField hfColorID = (HiddenField)gvr.FindControl("hfColorID");

                foreach (ListItem item in ddlPos_FabricsTypeAll.Items)
                {
                    ddlPos_FabricsType.Items.Add(item);
                }
                ddlPos_FabricsType.SelectedValue = "4";
                foreach (ListItem item in ddlPos_ColorAll.Items)
                {
                    ddlColor_Config.Items.Add(item);
                }
                ddlColor_Config.SelectedValue = "1";

            }
        }
        else
        {
            showAlartMessage("Please select the Product ");
        }
    }
예제 #16
0
    protected void btnAdd_Click(object sender, EventArgs e)
    {
        if (barCodeChecking())
        {
            return;
        }

        int TransactionMasterID = 0;
        int JournalMasterID = 0;
        if (txtOldTrasactionID.Text != "")
        {
            if (hfTransactionMasterID.Value == "0")
            {

                TransactionMasterID = int.Parse(GetTransactionMasterID().Split('@')[0]);
                JournalMasterID = int.Parse(GetTransactionMasterID().Split('@')[1]);
            }
            else
            {
                TransactionMasterID = int.Parse(hfTransactionMasterID.Value);
                JournalMasterID = int.Parse(hfJournalMasterID.Value);
            }

            if (TransactionMasterID == 0)
            {
                showAlartMessage("Wrong old ID");
                return;
            }
        }
        else
        {
            //Regenerate ta kon transaction master er under e probe?

            Pos_TransactionMaster pos_TransactionMaster = new Pos_TransactionMaster();

            pos_TransactionMaster.TransactionDate = DateTime.Parse(txtProductionDate.Text);
            pos_TransactionMaster.TransactionID = 0;
            pos_TransactionMaster.Pos_TransactionTypeID = (Request.QueryString["IsPurchased"] == null ? 1 : 25);
            pos_TransactionMaster.ToOrFromID = (Request.QueryString["IsPurchased"] != null ? int.Parse(ddlSuppier.SelectedValue) : int.Parse(ddlProductionUnit.SelectedValue));
            pos_TransactionMaster.Record = "";
            pos_TransactionMaster.Particulars = txtNote.Text;
            pos_TransactionMaster.WorkSatationID = (Request.QueryString["IsPurchased"] != null ? 1 : int.Parse(ddlProductionUnit.SelectedValue)); ;
            pos_TransactionMaster.ExtraField1 = "";
            pos_TransactionMaster.ExtraField2 = "";
            pos_TransactionMaster.ExtraField3 = "";
            pos_TransactionMaster.ExtraField4 = "";
            pos_TransactionMaster.ExtraField5 = "";
            pos_TransactionMaster.AddedBy = getLogin().LoginID;
            pos_TransactionMaster.AddedDate = DateTime.Now;
            pos_TransactionMaster.UpdatedBy = getLogin().LoginID;
            pos_TransactionMaster.UpdatedDate = DateTime.Now;
            pos_TransactionMaster.RowStatusID = 1;
            TransactionMasterID = Pos_TransactionMasterManager.InsertPos_TransactionMaster(pos_TransactionMaster);
            pos_TransactionMaster = Pos_TransactionMasterManager.GetPos_TransactionMasterByID(TransactionMasterID);

            txtOldTrasactionID.Text = pos_TransactionMaster.TransactionID.ToString();
            hfTransactionMasterID.Value = TransactionMasterID.ToString();

            if (Request.QueryString["IsPurchased"] != null)
            {
                //Journal Entry
                ACC_JournalMaster aCC_JournalMaster = new ACC_JournalMaster();

                aCC_JournalMaster.JournalMasterName = "3";//Journal Voucher
                aCC_JournalMaster.ExtraField1 = ddlSuppier.SelectedItem.Text;
                aCC_JournalMaster.ExtraField2 = "";
                aCC_JournalMaster.ExtraField3 = "";
                aCC_JournalMaster.Note = "Product Purchase-" + pos_TransactionMaster.TransactionID.ToString();
                aCC_JournalMaster.JournalDate = pos_TransactionMaster.TransactionDate;
                aCC_JournalMaster.AddedBy = getLogin().LoginID;
                aCC_JournalMaster.AddedDate = DateTime.Now;
                aCC_JournalMaster.UpdatedBy = getLogin().LoginID;
                aCC_JournalMaster.UpdatedDate = DateTime.Now;
                aCC_JournalMaster.RowStatusID = 1;

                JournalMasterID = ACC_JournalMasterManager.InsertACC_JournalMaster(aCC_JournalMaster);
                hfJournalMasterID.Value = JournalMasterID.ToString();
            }
        }
        Pos_Product pos_Product = new Pos_Product();
        pos_Product.ProductID = Int32.Parse(ddlProduct.SelectedValue);
        pos_Product.ReferenceID = TransactionMasterID;
        pos_Product.Pos_ProductTypeID = 1;
        pos_Product.ProductStatusID = Int32.Parse(ddlProductStatus.SelectedValue);
        pos_Product.ProductName = ddlProduct.SelectedItem.Text;
        pos_Product.Pos_BrandID = Int32.Parse(ddlPos_Brand.SelectedValue);
        pos_Product.Inv_QuantityUnitID = Int32.Parse(ddlInv_QuantityUnit.SelectedValue);

        pos_Product.Note = txtNote.Text;

        pos_Product.Pic1 = txtPicture.Value;
        pos_Product.Pic2 = "";
        pos_Product.Pic3 = "";
        pos_Product.VatPercentage = Decimal.Parse(txtVatPercentage.Text);
        pos_Product.IsVatExclusive = cbIsVatExclusive.Checked;
        pos_Product.DiscountPercentage = Decimal.Parse(txtDiscountPercentage.Text);
        pos_Product.FabricsNo = ddlProductionUnit.SelectedValue;
        pos_Product.ExtraField1 = "";
        pos_Product.ExtraField2 = "";
        pos_Product.ExtraField3 = "";
        pos_Product.ExtraField4 = "";
        pos_Product.ExtraField5 = "";
        pos_Product.ExtraField6 = "";
        pos_Product.ExtraField7 = "";
        pos_Product.ExtraField8 = "";
        pos_Product.ExtraField9 = ddlSuppier.SelectedValue;
        pos_Product.ExtraField10 = JournalMasterID.ToString();
        pos_Product.AddedBy = getLogin().LoginID;
        pos_Product.AddedDate = DateTime.Now;
        pos_Product.UpdatedBy = getLogin().LoginID;
        pos_Product.UpdatedDate = DateTime.Now;
        pos_Product.RowStatusID = 1;
        string ids = "";
        foreach (GridViewRow gvr in gvProductConfiguration.Rows)
        {
            /*
            <asp:HiddenField ID="hfColorID" runat="server" Value='<%#Eval("Pos_ColorID") %>'/>
                                <asp:HiddenField ID="hfPos_SizeID" runat="server" Value='<%#Eval("Pos_SizeID") %>'/>
                                <asp:HiddenField ID="hfFabricsCost" runat="server" Value='<%#Eval("FabricsCost") %>'/>
                                <asp:HiddenField ID="hfAccesoriesCost" runat="server" Value='<%#Eval("AccesoriesCost") %>'/>
                                <asp:HiddenField ID="hfOverhead" runat="server" Value='<%#Eval("Overhead") %>'/>
                                <asp:HiddenField ID="hfOthersCost" runat="server" Value='<%#Eval("OthersCost") %>'/>
                                <asp:HiddenField ID="hfUtilizationIDs" runat="server" Value='<%#Eval("Inv_UtilizationDetailsIDs") %>'/>
            */
            HiddenField hfColorID = (HiddenField)gvr.FindControl("hfColorID");
            HiddenField hfPos_SizeID = (HiddenField)gvr.FindControl("hfPos_SizeID");
            HiddenField hfFabricsCost = (HiddenField)gvr.FindControl("hfFabricsCost");
            HiddenField hfAccesoriesCost = (HiddenField)gvr.FindControl("hfAccesoriesCost");
            HiddenField hfOverhead = (HiddenField)gvr.FindControl("hfOverhead");
            HiddenField hfOthersCost = (HiddenField)gvr.FindControl("hfOthersCost");
            HiddenField hfUtilizationIDs = (HiddenField)gvr.FindControl("hfUtilizationIDs");
            HiddenField hfProductCode = (HiddenField)gvr.FindControl("hfProductCode");
            HiddenField hfDesignCode = (HiddenField)gvr.FindControl("hfDesignCode");
            HiddenField hfSizeCode = (HiddenField)gvr.FindControl("hfSizeCode");

            DropDownList ddlColor_Config = (DropDownList)gvr.FindControl("ddlColor_Config");
            DropDownList ddlPos_FabricsType = (DropDownList)gvr.FindControl("ddlPos_FabricsType");

            TextBox txtSalesPrice_Config = (TextBox)gvr.FindControl("txtSalesPrice_Config");
            TextBox txtCurrentProcessing = (TextBox)gvr.FindControl("txtCurrentProcessing");
            TextBox lblAgvCosting = (TextBox)gvr.FindControl("lblAgvCosting");

            TextBox lblBarCode = (TextBox)gvr.FindControl("lblBarCode");

            pos_Product.Inv_UtilizationDetailsIDs = hfUtilizationIDs.Value;
            pos_Product.Pos_SizeID = Int32.Parse(hfPos_SizeID.Value);

            pos_Product.FabricsCost = Decimal.Parse(hfFabricsCost.Value);
            pos_Product.AccesoriesCost = Decimal.Parse(hfAccesoriesCost.Value);
            pos_Product.Overhead = Decimal.Parse(hfOverhead.Value);
            pos_Product.OthersCost = Decimal.Parse(hfOthersCost.Value);
            pos_Product.PurchasePrice = (Request.QueryString["IsPurchased"] == null?0:Decimal.Parse(lblAgvCosting.Text));
            pos_Product.SalePrice = Decimal.Parse(txtSalesPrice_Config.Text);
            pos_Product.OldSalePrice =0;

            pos_Product.DiscountAmount =((pos_Product.SalePrice * Decimal.Parse(txtDiscountPercentage.Text))/100);

            pos_Product.Pos_ColorID = Int32.Parse(ddlColor_Config.SelectedValue);
            pos_Product.Pos_FabricsTypeID = Int32.Parse(ddlPos_FabricsType.SelectedValue);
            pos_Product.ExtraField1 = txtCurrentProcessing.Text;
            pos_Product.DesignCode = hfDesignCode.Value;
            pos_Product.BarCode = lblBarCode.Text;

            pos_Product.StyleCode = txtStyle.Text;//getStyleCode(pos_Product);
            int productID = Pos_ProductManager.InsertPos_Product(pos_Product);

            ids += (ids != "" ? "," : "") + productID.ToString();
        }

        SaveForRemoteDB(ids);

        processUtilizationDetails(TransactionMasterID);

        hlnkProductionPrint.Visible = true;
        hlnkProductionPrint.NavigateUrl = "TransactionPrint.aspx?Pos_TransactionMasterID="+TransactionMasterID.ToString();
        btnClear_Click(this, new EventArgs());
    }
예제 #17
0
파일: Sales.aspx.cs 프로젝트: anam/gp-HO
    protected void lbDeletePreviewGrid_Click(object sender, EventArgs e)
    {
        LinkButton linkButton = new LinkButton();
        linkButton = (LinkButton)sender;
        int id = Convert.ToInt32(linkButton.CommandArgument);

        List<Pos_Product> takenFromPreviewProduct = new List<Pos_Product>();

        foreach (GridViewRow gvr in gvPreview.Rows)
        {
            Pos_Product prod = new Pos_Product();

            HiddenField hfPos_ProductID = (HiddenField)gvr.FindControl("hfPos_ProductID");

            Label lblProductName = (Label)gvr.FindControl("lblProductName");
            Label lblBarCode = (Label)gvr.FindControl("lblBarCode");
            Label lblSizeName = (Label)gvr.FindControl("lblSizeName");
            Label lblColorName = (Label)gvr.FindControl("lblColorName");
            Label lblProductStatusName = (Label)gvr.FindControl("lblProductStatusName");
            Label lblStock = (Label)gvr.FindControl("lblStock");
            Label lblSalePrice = (Label)gvr.FindControl("lblSalePrice");
            Label lblStockSalePrice = (Label)gvr.FindControl("lblStockSalePrice");

            TextBox txtQty = (TextBox)gvr.FindControl("txtQty");
            TextBox txtVatGrid = (TextBox)gvr.FindControl("txtVatGrid");
            TextBox txtDiscountGrid = (TextBox)gvr.FindControl("txtDiscountGrid");
            TextBox txtDiscountAmountGrid = (TextBox)gvr.FindControl("txtDiscountAmountGrid");

            prod.Pos_ProductID = int.Parse(hfPos_ProductID.Value);
            prod.ProductName = lblProductName.Text;
            prod.BarCode = lblBarCode.Text;
            prod.ExtraField1 = txtQty.Text;
            prod.ExtraField10 = lblSizeName.Text;
            prod.ExtraField2 = lblColorName.Text;
            prod.ExtraField3 = lblProductStatusName.Text;
            prod.ExtraField4 = lblStock.Text;
            prod.ExtraField5 = lblSalePrice.Text;
            prod.ExtraField6 = (decimal.Parse(lblSalePrice.Text) * decimal.Parse(txtQty.Text)).ToString("0,0.00");
            prod.ExtraField7 = "0";//not fund
            prod.DiscountAmount = decimal.Parse(txtDiscountAmountGrid.Text) != 0 ? (decimal.Parse(txtDiscountAmountGrid.Text)) : ((decimal.Parse(lblSalePrice.Text) * decimal.Parse(txtQty.Text)) * (decimal.Parse(txtDiscountGrid.Text) / 100));
            prod.ExtraField8 = decimal.Parse(txtVatGrid.Text) == 0 ? "0.00" : ((decimal.Parse(prod.ExtraField6) - prod.DiscountAmount) * (decimal.Parse(txtVatGrid.Text) / 100)).ToString("0,0.00");
            prod.ExtraField9 = (decimal.Parse(prod.ExtraField6) - prod.DiscountAmount + decimal.Parse(prod.ExtraField8)).ToString("0,0.00");

            prod.AccesoriesCost = decimal.Parse(prod.ExtraField8);
            prod.FabricsCost = prod.DiscountAmount;

            //Rewrite
            prod.ExtraField8 = txtVatGrid.Text;
            prod.DiscountAmount = decimal.Parse(txtDiscountAmountGrid.Text);
            prod.DiscountPercentage = decimal.Parse(txtDiscountGrid.Text);

            if (txtQty.Text != "0")
                takenFromPreviewProduct.Add(prod);
        }

        int deleted_i = -1;
        for (int i = 0; i < takenFromPreviewProduct.Count; i++)
        {
            if (id == takenFromPreviewProduct[i].Pos_ProductID)
            {
                deleted_i = i;
                break;
            }
        }
        if (deleted_i != -1)
        {
            takenFromPreviewProduct.Remove(takenFromPreviewProduct[deleted_i]);
        }

        gvPreview.DataSource = takenFromPreviewProduct;
        gvPreview.DataBind();

        decimal totalStock = 0;
        decimal qty = 0;
        decimal totalAmount = 0;
        decimal SubtotalAmount = 0;
        decimal discountSum = 0;
        decimal vatSum = 0;
        foreach (Pos_Product prod in takenFromPreviewProduct)
        {
            totalAmount += decimal.Parse(prod.ExtraField6);
            SubtotalAmount += decimal.Parse(prod.ExtraField9);
            totalStock += decimal.Parse(prod.ExtraField4);
            qty += decimal.Parse(prod.ExtraField1);
            vatSum += prod.AccesoriesCost;
            discountSum += prod.FabricsCost;
        }

        ((Label)gvPreview.FooterRow.FindControl("lblStockFooter")).Text = totalStock.ToString("0,0");
        ((Label)gvPreview.FooterRow.FindControl("lblStockSalePriceFooter")).Text = totalAmount.ToString("0,0.00");
        ((Label)gvPreview.FooterRow.FindControl("lblQtyFooter")).Text = qty.ToString("0,0");
        ((Label)gvPreview.FooterRow.FindControl("lblSubTotalSalePriceFooter")).Text = SubtotalAmount.ToString("0,0.00");
        ((Label)gvPreview.FooterRow.FindControl("lblDiscountAmountTotalFooter")).Text = discountSum.ToString("0,0.00");
        ((Label)gvPreview.FooterRow.FindControl("lblVatGridTotalFooter")).Text = vatSum.ToString("0,0.00");

        txtSubTotal.Text = totalAmount.ToString("0,0.00");
        txtVat.Text = vatSum.ToString("0,0.00");
        txtDiscount.Text = discountSum.ToString("0,0.00");

        lblTotalQty.Text = qty.ToString("0,0");

        txtCashAmount_TextChanged(this, new EventArgs());
    }
예제 #18
0
    protected void btnProcessProduction_Click(object sender, EventArgs e)
    {
        if (ddlProduct.SelectedValue != "0" && rbtnProductType.SelectedValue != "All")
        {

            List<Pos_Product> configuringProdut = new List<Pos_Product>();

            foreach (GridViewRow gvr in gvInv_UtilizationDetails.Rows)
            {
                TextBox txtCurrentProcess = (TextBox)gvr.FindControl("txtCurrentProcess");

                CheckBox chkSelect = (CheckBox)gvr.FindControl("chkSelect");
                if(txtCurrentProcess.Text=="")
                {
                    continue;
                }

                if (chkSelect.Checked && decimal.Parse(txtCurrentProcess.Text)>0)
                {
                    HiddenField hfColorID = (HiddenField)gvr.FindControl("hfColorID");
                    HiddenField hfPos_SizeID = (HiddenField)gvr.FindControl("hfPos_SizeID");
                    HiddenField hfRemainingQty = (HiddenField)gvr.FindControl("hfRemainingQty");
                    Label lblSizeName=(Label)gvr.FindControl("lblSizeName");
                    Label lblFabricsCost = (Label)gvr.FindControl("lblFabricsCost");
                    Label lblAccesoriesCost = (Label)gvr.FindControl("lblAccesoriesCost");
                    Label lblOverhead = (Label)gvr.FindControl("lblOverhead");
                    Label lblOthersCost = (Label)gvr.FindControl("lblOthersCost");

                    if (decimal.Parse(hfRemainingQty.Value) < decimal.Parse(txtCurrentProcess.Text))
                    {
                        showAlartMessage("Current processing qty can not be more than available qty");
                        return;
                    }

                    bool isFound = false;
                    foreach (Pos_Product prod in configuringProdut)
                    {
                        if (prod.Pos_SizeID.ToString() == hfPos_SizeID.Value)
                        {
                            isFound = true;
                            prod.Inv_UtilizationDetailsIDs = "," + chkSelect.ToolTip;
                            prod.ExtraField1 = (decimal.Parse(prod.ExtraField1)+decimal.Parse(txtCurrentProcess.Text)).ToString("0.00");
                            prod.FabricsCost += decimal.Parse(lblFabricsCost.Text) * decimal.Parse(txtCurrentProcess.Text);
                            prod.AccesoriesCost += decimal.Parse(lblAccesoriesCost.Text) * decimal.Parse(txtCurrentProcess.Text);
                            prod.Overhead += decimal.Parse(lblOverhead.Text) * decimal.Parse(txtCurrentProcess.Text);
                            prod.OthersCost += decimal.Parse(lblOthersCost.Text) * decimal.Parse(txtCurrentProcess.Text);
                            prod.Pos_ColorID = int.Parse(hfColorID.Value);
                            break;
                        }
                    }

                    if (!isFound)
                    {
                        Pos_Product prod = new Pos_Product();
                        prod.Inv_UtilizationDetailsIDs = chkSelect.ToolTip;
                        prod.Pos_SizeID = int.Parse(hfPos_SizeID.Value);
                        prod.ExtraField2 = lblSizeName.Text;
                        prod.ExtraField1 = txtCurrentProcess.Text;
                        prod.FabricsCost = decimal.Parse(lblFabricsCost.Text) * decimal.Parse(txtCurrentProcess.Text);
                        prod.AccesoriesCost = decimal.Parse(lblAccesoriesCost.Text) * decimal.Parse(txtCurrentProcess.Text);
                        prod.Overhead = decimal.Parse(lblOverhead.Text) * decimal.Parse(txtCurrentProcess.Text);
                        prod.OthersCost = decimal.Parse(lblOthersCost.Text) * decimal.Parse(txtCurrentProcess.Text);
                        prod.Pos_ColorID = int.Parse(hfColorID.Value);

                        configuringProdut.Add(prod);
                    }
                }
            }
            string sizeIDs = "";
            foreach (Pos_Product prod in configuringProdut)
            {
                prod.ExtraField3 = ((prod.FabricsCost + prod.AccesoriesCost + prod.Overhead + prod.OthersCost) / (decimal.Parse(prod.ExtraField1))).ToString("0.00");
                prod.FabricsCost = prod.FabricsCost / decimal.Parse(prod.ExtraField1);
                prod.AccesoriesCost = prod.AccesoriesCost / decimal.Parse(prod.ExtraField1);
                prod.Overhead = prod.Overhead / decimal.Parse(prod.ExtraField1);
                prod.OthersCost = prod.OthersCost / decimal.Parse(prod.ExtraField1);

                if (sizeIDs != "") sizeIDs += ",";
                sizeIDs += prod.Pos_SizeID.ToString();
            }

            string sql = "Select ExtraField1,ExtraField2 from ACC_ChartOfAccountLabel4 where ACC_ChartOfAccountLabel4ID=" + ddlProduct.SelectedValue + ";";
            sql += @"SELECT [Pos_SizeID]
                          ,[SizeName]
                          ,[Code]
                      FROM [Pos_Size]
                      where Pos_SizeID in ("+sizeIDs+");";

            DataSet ds = CommonManager.SQLExec(sql);

            foreach (Pos_Product prod in configuringProdut)
            {
                prod.DesignCode = decimal.Parse((ds.Tables[0].Rows[0]["ExtraField2"].ToString() ==""?"1":ds.Tables[0].Rows[0]["ExtraField2"].ToString())).ToString("00000");
                txtDesignCode.Text = prod.DesignCode;
                prod.ExtraField4 = ds.Tables[0].Rows[0]["ExtraField1"].ToString();
                foreach (DataRow dr in ds.Tables[1].Rows)
                {
                    if (prod.Pos_SizeID.ToString() == dr["Pos_SizeID"].ToString())
                    {
                        prod.ExtraField5 = dr["Code"].ToString();
                    }
                }
                prod.BarCode = prod.ExtraField4 + prod.DesignCode + prod.ExtraField5;
            }

            gvProductConfiguration.DataSource=configuringProdut;
            gvProductConfiguration.DataBind();

            foreach (GridViewRow gvr in gvProductConfiguration.Rows)
            {
                DropDownList ddlColor_Config = (DropDownList)gvr.FindControl("ddlColor_Config");
                DropDownList ddlPos_FabricsType = (DropDownList)gvr.FindControl("ddlPos_FabricsType");
                HiddenField hfColorID = (HiddenField)gvr.FindControl("hfColorID");

                TextBox lblAgvCosting = (TextBox)gvr.FindControl("lblAgvCosting");
                TextBox txtCurrentProcessing = (TextBox)gvr.FindControl("txtCurrentProcessing");
                lblAgvCosting.Enabled = false;
                txtCurrentProcessing.Enabled = false;

                foreach (ListItem item in ddlPos_FabricsTypeAll.Items)
                {
                    ddlPos_FabricsType.Items.Add(item);
                }
                ddlPos_FabricsType.SelectedValue = "4";
                foreach (ListItem item in ddlPos_ColorAll.Items)
                {
                    ddlColor_Config.Items.Add(item);
                }
                if (hfColorID.Value != "")
                {
                    ddlColor_Config.SelectedValue = hfColorID.Value;
                }
                else
                {
                    ddlColor_Config.SelectedValue = "1";

                }
            }

        }
        else
        {
            showAlartMessage("Please select the Product and/or Product type");
        }
    }
예제 #19
0
파일: Sales.aspx.cs 프로젝트: anam/gp-HO
    private void recalculate()
    {
        List<Pos_Product> takenFromPreviewProduct = new List<Pos_Product>();

        foreach (GridViewRow gvr in gvPreview.Rows)
        {
            Pos_Product prod = new Pos_Product();

            HiddenField hfPos_ProductID = (HiddenField)gvr.FindControl("hfPos_ProductID");

            Label lblProductName = (Label)gvr.FindControl("lblProductName");
            Label lblBarCode = (Label)gvr.FindControl("lblBarCode");
            Label lblSizeName = (Label)gvr.FindControl("lblSizeName");
            Label lblColorName = (Label)gvr.FindControl("lblColorName");
            Label lblProductStatusName = (Label)gvr.FindControl("lblProductStatusName");
            Label lblStock = (Label)gvr.FindControl("lblStock");
            Label lblSalePrice = (Label)gvr.FindControl("lblSalePrice");
            Label lblStockSalePrice = (Label)gvr.FindControl("lblStockSalePrice");

            TextBox txtQty = (TextBox)gvr.FindControl("txtQty");
            TextBox txtVatGrid = (TextBox)gvr.FindControl("txtVatGrid");
            TextBox txtDiscountGrid = (TextBox)gvr.FindControl("txtDiscountGrid");
            TextBox txtDiscountAmountGrid = (TextBox)gvr.FindControl("txtDiscountAmountGrid");
            TextBox txtVatGridTotal = (TextBox)gvr.FindControl("txtVatGridTotal");

            if (decimal.Parse(lblStock.Text) < decimal.Parse(txtQty.Text))
            {
                showAlartMessage(lblBarCode.Text +" Stock is less than your given Quantity");
                continue;
            }

            prod.Pos_ProductID = int.Parse(hfPos_ProductID.Value);
            prod.ProductName = lblProductName.Text;
            prod.BarCode = lblBarCode.Text;
            prod.ExtraField1 = txtQty.Text;
            prod.ExtraField10 = lblSizeName.Text;
            prod.ExtraField2 = lblColorName.Text;
            prod.ExtraField3 = lblProductStatusName.Text;
            prod.ExtraField4 = lblStock.Text;

            decimal acctualSalesAmount = decimal.Parse(lblSalePrice.Text);
            decimal acctualSalesAmountTotal = decimal.Parse(lblSalePrice.Text) * decimal.Parse(txtQty.Text);

            prod.ExtraField5 = (acctualSalesAmount).ToString("0,0");
            prod.ExtraField6 = (decimal.Parse(prod.ExtraField5) * decimal.Parse(txtQty.Text)).ToString("0,0");
            prod.DiscountAmount = decimal.Parse(txtDiscountAmountGrid.Text) != 0 ? (decimal.Parse(txtDiscountAmountGrid.Text) * decimal.Parse(txtQty.Text)) : ((decimal.Parse(prod.ExtraField6)) * (decimal.Parse(txtDiscountGrid.Text) / 100));
            prod.DiscountAmount = decimal.Parse(prod.DiscountAmount.ToString("0,0"));
            prod.ExtraField8 = decimal.Parse(txtVatGridTotal.Text).ToString("0,0");
            prod.ExtraField9 = (decimal.Parse(prod.ExtraField6) - prod.DiscountAmount + decimal.Parse(prod.ExtraField8)).ToString("0,0");
            prod.ExtraField7 = "0";//not fund

            prod.AccesoriesCost = decimal.Parse(prod.ExtraField8);
            prod.ExtraField8 = txtVatGrid.Text;
            prod.FabricsCost = prod.DiscountAmount;

            //Rewrite
            //prod.ExtraField8 = txtVatGrid.Text;
            prod.DiscountAmount = decimal.Parse(txtDiscountAmountGrid.Text);
            prod.DiscountPercentage = decimal.Parse(txtDiscountGrid.Text);

            if (txtQty.Text != "0")
                takenFromPreviewProduct.Add(prod);
        }

        gvPreview.DataSource = takenFromPreviewProduct;
        gvPreview.DataBind();

        decimal totalStock = 0;
        decimal qty = 0;
        decimal totalAmount = 0;
        decimal SubtotalAmount = 0;
        decimal discountSum = 0;
        decimal vatSum = 0;
        foreach (Pos_Product prod in takenFromPreviewProduct)
        {
            totalAmount += decimal.Parse(prod.ExtraField6);
            SubtotalAmount += decimal.Parse(prod.ExtraField9);
            totalStock += decimal.Parse(prod.ExtraField4);
            qty += decimal.Parse(prod.ExtraField1);
            vatSum += prod.AccesoriesCost;
            discountSum += prod.FabricsCost;
        }

        ((Label)gvPreview.FooterRow.FindControl("lblStockFooter")).Text = totalStock.ToString("0,0");
        ((Label)gvPreview.FooterRow.FindControl("lblStockSalePriceFooter")).Text = totalAmount.ToString("0,0.00");
        ((Label)gvPreview.FooterRow.FindControl("lblQtyFooter")).Text = qty.ToString("0,0");
        ((Label)gvPreview.FooterRow.FindControl("lblSubTotalSalePriceFooter")).Text = SubtotalAmount.ToString("0,0.00");
        ((Label)gvPreview.FooterRow.FindControl("lblDiscountAmountTotalFooter")).Text = discountSum.ToString("0,0.00");
        ((Label)gvPreview.FooterRow.FindControl("lblVatGridTotalFooter")).Text = vatSum.ToString("0,0.00");

        txtSubTotal.Text = totalAmount.ToString("0,0.00");
        txtVat.Text = vatSum.ToString("0,0.00");
        txtDiscount.Text = discountSum.ToString("0,0.00");

        lblTotalQty.Text = qty.ToString("0,0");

        txtCashAmount_TextChanged(this, new EventArgs());
    }
예제 #20
0
    private string getStyleCode(Pos_Product prod)
    {
        string StyleCode = "";

        foreach (string  item in prod.ProductName.Split(' '))
        {
            StyleCode += item.Substring(0,1).ToUpper();
        }

        return StyleCode +"-"+prod.DesignCode;
    }
예제 #21
0
파일: Sales.aspx.cs 프로젝트: anam/gp-HO
    protected void btnSubmit_Click(object sender, EventArgs e)
    {
        foreach (GridViewRow gvr in gvPreview.Rows)
        {
            HiddenField hfPos_ProductID = (HiddenField)gvr.FindControl("hfPos_ProductID");
            TextBox txtQty = (TextBox)gvr.FindControl("txtQty");
            TextBox txtDiscountAmountTotal = (TextBox)gvr.FindControl("txtDiscountAmountTotal");
            TextBox txtVatGridTotal = (TextBox)gvr.FindControl("txtVatGridTotal");
            Label lblSubTotalSalePrice = (Label)gvr.FindControl("lblSubTotalSalePrice");
            Label lblStock = (Label)gvr.FindControl("lblStock");
            HiddenField hfVatPercentageAlways = (HiddenField)gvr.FindControl("hfVatPercentageAlways");
            HiddenField hfTotalCostPerProduct = (HiddenField)gvr.FindControl("hfTotalCostPerProduct");

            try
            {
                if (decimal.Parse(txtQty.Text) > decimal.Parse(lblStock.Text))
                {
                    showAlartMessage("Sale quantity can not be more than stock");
                }
            }
            catch (Exception dex)
            {
                showAlartMessage("Sale quantity can not be more than stock");
                return;
            }
        }
        if (txtDiscountPercentage.Text == "")
        {
            showAlartMessage("Discount amount can not be blank. if no discount then keep 0");
            return;

        }

        //this will be applied by card
        if (txtDiscountPercentage.Enabled && ddlRefference.SelectedValue == "0")
        {
            if (txtDiscountPercentage.Text != "" && decimal.Parse(txtDiscountPercentage.Text) > 0)
            {
                //showAlartMessage("Without refference the discount can not be applied");
                //return;
            }
            else
            {
                if (!ddlRefference.SelectedItem.Text.Contains("00"))
                {
                    if (decimal.Parse(txtDiscountPercentage.Text) > 35)
                    {
                        showAlartMessage("Employee can not give more than 35%");
                        return;
                    }
                }
            }
        }

        CompleteTheAutoCalculation();

        if (decimal.Parse(txtReturnAmount.Text) > decimal.Parse(txtPayableAmount.Text))
        {
            showAlartMessage("We can not Refund the money please buy other more product.");
            return;
        }

        if (decimal.Parse(txtRefundOrDue.Text) < 0)
        {
            showAlartMessage("Payment amount is less than the billing Amount");
            return;
        }

        if (decimal.Parse(txtRefundOrDue.Text) > decimal.Parse(txtCashAmount.Text)
            )
        {
            showAlartMessage("Your cash payment is less than refund amount");
            return;
        }

        string SQL_new = @"Declare @Pos_SalesReturnMasterID int;
               Set  @Pos_SalesReturnMasterID= "+getLogin().LoginID+@"
        ";
        bool isRetrun = false;

        if (Request.QueryString["TransactionTypeID"] =="14")
        {

            foreach (GridViewRow gvr in gvReturnInvoice.Rows)
            {
                TextBox txtRtnQty = (TextBox)gvr.FindControl("txtRtnQty");
                Label lblSoldQty = (Label)gvr.FindControl("lblSoldQty");
                Label lblInvoiceNo = (Label)gvr.FindControl("lblInvoiceNo");
                Label lblBarCode = (Label)gvr.FindControl("lblBarCode");
                Label lblDiscountAmount = (Label)gvr.FindControl("lblDiscountAmount");
                Label lblVat = (Label)gvr.FindControl("lblVat");

                Label lblSalePrice = (Label)gvr.FindControl("lblSalePrice");
                Label lblStockSalePrice = (Label)gvr.FindControl("lblStockSalePrice");
                Label lblTotal = (Label)gvr.FindControl("lblTotal");

                HiddenField hfPos_TransactionID = (HiddenField)gvr.FindControl("hfPos_TransactionID");
                HiddenField hfPos_TransactionMasterID = (HiddenField)gvr.FindControl("hfPos_TransactionMasterID");
                HiddenField hfPos_ProductID = (HiddenField)gvr.FindControl("hfPos_ProductID");

                HiddenField hfVatPercentageAlways = (HiddenField)gvr.FindControl("hfVatPercentageAlways");
                HiddenField hfTotalCostPerProduct = (HiddenField)gvr.FindControl("hfTotalCostPerProduct");

                if (txtRtnQty.Text != "0" && txtRtnQty.Text != "")
                {
                    if (!isRetrun)
                    {
                        #region Sales Return Master
                        SQL_new += @"
                        INSERT INTO [Pos_SalesReturnMaster]
                           ([LocalSalesReturnMasterID]
                           ,[InvoiceNo]
                           ,[WorkStationID]
                           ,[SalesDate]
                           ,[SalesReturnID]
                           ,[CashSales]
                           ,[CashSalesJournalDetailID]
                           ,[DBBLAmount]
                           ,[CityAmount]
                           ,[VATPercentage]
                           ,[VATAmount]
                           ,[DiscountPercentage]
                           ,[DiscountAmount]
                           ,[RefundAmount]
                           ,[SalesPerson]
                           ,[Referrence]
                           ,[Customer]
                           ,[MobileNo]
                           ,[CustomerName]
                           ,[Note]
                           ,[LocalJournalMasterID]
                           ,[LocalTransactionMasterID]
                           ,[LocalReturnTransactionMasterID]
                           ,[ServerJournalMasterID]
                           ,[ServerTransactionMasterID]
                           ,[ServerReturnTransactionMasterID]
                           ,[StatusID]
                           ,[ExtraField1]
                           ,[ExtraField2]
                           ,[ExtraField3]
                           ,[ExtraField4]
                           ,[ExtraField5]
                           ,[ExtraField6]
                           ,[ExtraField7]
                           ,[ExtraField8]
                           ,[ExtraField9]
                           ,[ExtraField10])
                     VALUES
                           (
                            0--<LocalSalesReturnMasterID, int,>
                           ," + lblInvoiceNo.Text + @"--<InvoiceNo, int,>
                           ," +ddlWorkStationSearch.SelectedValue +@"--<WorkStationID, int,>
                           ,'" + (txtBackDatedSale.Text == DateTime.Now.ToString("dd MMM yyyy") ? DateTime.Now : DateTime.Parse(txtBackDatedSale.Text)) + @"'--<SalesDate, datetime,>
                           ,0--<SalesReturnID, int,>
                           ,0--<CashSales, decimal(18,2),>
                           ,0--<CashSalesJournalDetailID, int,>
                           ,0--<DBBLAmount, decimal(18,2),>
                           ,0--<CityAmount, decimal(18,2),>
                           ,0--<VATPercentage, decimal(18,2),>
                           ,0--<VATAmount, decimal(18,2),>
                           ,0--<DiscountPercentage, decimal(18,2),>
                           ,0--<DiscountAmount, decimal(18,2),>
                           ,0--<RefundAmount, decimal(18,2),>
                           ," + ddlSalesPerson.SelectedValue + @"--<SalesPerson, int,>
                           ,0--<Referrence, int,>
                           ," + (txtCustomerID.Text == "" ? "0" : txtCustomerID.Text) + @"--<Customer, int,>
                           ,'" + txtContactNo.Text + @"'--<MobileNo, nvarchar(50),>
                           ,'" + txtCustomerName.Text + @"'--<CustomerName, nvarchar(50),>
                           ,''--<Note, ntext,>
                           ,0--<LocalJournalMasterID, int,>
                           ,0--<LocalTransactionMasterID, int,>
                           ,0--<LocalReturnTransactionMasterID, int,>
                           ,0--<ServerJournalMasterID, int,>
                           ,0--<ServerTransactionMasterID, int,>
                           ,0--<ServerReturnTransactionMasterID, int,>
                           ,0--<StatusID, int,>
                           ,'" + decimal.Parse(txtReturnAmount.Text ).ToString("0.00")+ @"'--<ExtraField1, nvarchar(256),>
                           ,''--<ExtraField2, nvarchar(256),>
                           ,''--<ExtraField3, nvarchar(256),>
                           ,''--<ExtraField4, nvarchar(256),>
                           ,'" + txtCardNo.Text + @"'--<ExtraField5, nvarchar(256),>
                           ,''--<ExtraField6, nvarchar(256),>
                           ,''--<ExtraField7, nvarchar(256),>
                           ,''--<ExtraField8, nvarchar(256),>
                           ,''--<ExtraField9, nvarchar(256),>
                           ,''--<ExtraField10, nvarchar(256),>
                    );
                    set @Pos_SalesReturnMasterID =SCOPE_IDENTITY();

                    ";

                        #endregion

                        isRetrun = true;
                    }

                    #region Sales Return Details
                     SQL_new += @"
                        INSERT INTO [Pos_SalesReturnDetail]
                           ([Pos_SalesReturnMasterID]
                            ,[LocalSalesDetailID]
                           ,[RemoteSalesDetailID]
                           ,[ProductID]
                           ,[Quantity]
                           ,[WorkStationID]
                           ,[CostPrice]
                           ,[SalesPrice]
                           ,[DiscountPercentage]
                           ,[DiscountAmount]
                           ,[VATPercentage]
                           ,[VATAmount]
                           ,[LocalPos_TransactionMasterID]
                           ,[SererPos_TransactionMasterID]
                           ,[LocalTransactionID]
                           ,[ServerTransactionID]
                           ,[LocalPos_SalesMasterID]
                           ,[ServerPos_SalesMasterID]
                           ,[LocalFinishedGoodAssetJournalDetailID]
                           ,[LocalCostOfGoodsSoldJournalDetailID]
                           ,[LocalSalesRevinueJournalDetailID]
                           ,[LocalVATIncludingJournalDetailID]
                           ,[LocalVATExcludingJournalDetailID]
                           ,[LocalDiscountJournalDetailID]
                           ,[ServerFinishedGoodAssetJournalDetailID]
                           ,[ServerCostOfGoodsSoldJournalDetailID]
                           ,[ServerSalesRevinueJournalDetailID]
                           ,[ServerVATIncludingJournalDetailID]
                           ,[ServerVATExcludingJournalDetailID]
                           ,[ServerDiscountJournalDetailID]
                           ,[StatusID]
                           ,[ExtraField1]
                           ,[ExtraField2]
                           ,[ExtraField3]
                           ,[ExtraField4]
                           ,[ExtraField5]
                           ,[ExtraField6]
                           ,[ExtraField7]
                           ,[ExtraField8]
                           ,[ExtraField9]
                           ,[ExtraField10])
                     VALUES
                           (@Pos_SalesReturnMasterID
                            ,"+"0"+@"--LocalSalesDetailID, int,>
                           ,"+"0"+@"--RemoteSalesDetailID, int,>
                           ,"+hfPos_ProductID.Value+@"--ProductID, int,>
                           ," + txtRtnQty.Text + @"--Quantity, int,>
                           ," + ddlWorkStationSearch.SelectedValue + @"--WorkStationID, int,>
                           ," +"0"+@"--CostPrice, decimal(18,2),>
                           ," + (decimal.Parse(lblSalePrice.Text)).ToString("0") + @"--SalesPrice, decimal(18,2),>
                           ," +"0"+@"--DiscountPercentage, decimal(18,2),>
                           ," + (lblDiscountAmount.Text == "" ? "0" : lblDiscountAmount.Text) + @"--DiscountAmount, decimal(18,2),>
                           ," + hfVatPercentageAlways.Value + @"--VATPercentage, decimal(18,2),>
                           ," + (lblVat.Text == "" ? "0" : lblVat.Text) + @"--VATAmount, decimal(18,2),>
                           ," +"0"+@"--LocalPos_TransactionMasterID, int,>
                           ,"+"0"+@"--SererPos_TransactionMasterID, int,>
                           ,"+"0"+@"--LocalTransactionID, int,>
                           ,"+"0"+@"--ServerTransactionID, int,>
                           ,"+"0"+@"--LocalPos_SalesMasterID, int,>
                           ,"+"0"+@"--ServerPos_SalesMasterID, int,>
                           ,"+"0"+@"--LocalFinishedGoodAssetJournalDetailID, int,>
                           ,"+"0"+@"--LocalCostOfGoodsSoldJournalDetailID, int,>
                           ,"+"0"+@"--LocalSalesRevinueJournalDetailID, int,>
                           ,"+"0"+@"--LocalVATIncludingJournalDetailID, int,>
                           ,"+"0"+@"--LocalVATExcludingJournalDetailID, int,>
                           ,"+"0"+@"--LocalDiscountJournalDetailID, int,>
                           ,"+"0"+@"--ServerFinishedGoodAssetJournalDetailID, int,>
                           ,"+"0"+@"--ServerCostOfGoodsSoldJournalDetailID, int,>
                           ,"+"0"+@"--ServerSalesRevinueJournalDetailID, int,>
                           ,"+"0"+@"--ServerVATIncludingJournalDetailID, int,>
                           ,"+"0"+@"--ServerVATExcludingJournalDetailID, int,>
                           ,"+"0"+@"--ServerDiscountJournalDetailID, int,>
                           ,"+"0"+@"--StatusID, int,>
                           ,'" + ((decimal.Parse(lblDiscountAmount.Text) / decimal.Parse(lblSoldQty.Text)) * decimal.Parse(txtRtnQty.Text)).ToString("0,0.00") + @"'--ExtraField1, nvarchar(256),>
                           ,'" + lblTotal.Text + @"'--ExtraField2, nvarchar(256),> total
                           ,'" + ((decimal.Parse(lblVat.Text) / decimal.Parse(lblSoldQty.Text)) * decimal.Parse(txtRtnQty.Text)).ToString("0,0.00") + @"'--ExtraField3, nvarchar(256),>
                           ,'" + hfPos_TransactionID.Value + @"'--ExtraField4, nvarchar(256),>
                           ,'" + ddlRefference.SelectedValue + @"'--ExtraField5, nvarchar(256),>
                           ,'" + lblBarCode.Text.Trim() + @"'--ExtraField6, nvarchar(256),> BarCode
                           ,'" + hfPos_TransactionID.Value + @"'--ExtraField7, nvarchar(256),> TransactionID
                           ,'" + lblStockSalePrice.Text + @"'--ExtraField8, nvarchar(256),> StockSalePrice
                           ,'" + lblSoldQty.Text + @"'--ExtraField9, nvarchar(256),>SoldQty
                           ,'" + hfPos_TransactionMasterID.Value + @"'--ExtraField10, nvarchar(256),>
                );

                ";
                    #endregion

                }
            }
        }

        int transactionTypeID = 13;//int.Parse(Request.QueryString["TransactionTypeID"]);

        SQL_new += @"
                Declare @Pos_SalesMasterID int; ";

        int TransactionMasterID = 0;
        if (txtOldTransactionID.Text != "")
        {
            if (txtOldTransactionID.Text != "0")
            {
                TransactionMasterID = int.Parse(GetTransactionMasterID());
                SQL_new += @"
                Set  @Pos_SalesMasterID =" + TransactionMasterID.ToString() + "; ";
            }
            else
            {
                TransactionMasterID = int.Parse(txtOldTransactionID.Text);
            }

            if (TransactionMasterID == 0)
            {
                showAlartMessage("Wrong old ID");
                return;
            }
        }
        else
        {
            Pos_Product PaymentGrid_cardPayment = new Pos_Product();
            PaymentGrid_cardPayment.ExtraField1 = "";
            PaymentGrid_cardPayment.ExtraField2 = "";
            PaymentGrid_cardPayment.ExtraField3 = "0";
            PaymentGrid_cardPayment.ExtraField4 = "0";
            PaymentGrid_cardPayment.ExtraField5 = "0";
            foreach (GridViewRow gvr in gvPayment.Rows)
            {
                HiddenField hfSerial = (HiddenField)gvr.FindControl("hfSerial");
                HiddenField hfIssueFromID = (HiddenField)gvr.FindControl("hfIssueFromID");
                Label lblCardNo = (Label)gvr.FindControl("lblCardNo");
                Label lblCardType = (Label)gvr.FindControl("lblCardType");
                Label lblIssueFrom = (Label)gvr.FindControl("lblIssueFrom");
                Label lblAmount = (Label)gvr.FindControl("lblAmount");

                PaymentGrid_cardPayment.ExtraField1 = lblCardNo.Text;
                PaymentGrid_cardPayment.ExtraField2 = lblCardType.Text;
                PaymentGrid_cardPayment.ExtraField3 = lblIssueFrom.Text;
                PaymentGrid_cardPayment.ExtraField4 = hfIssueFromID.Value;
                PaymentGrid_cardPayment.ExtraField5 = lblAmount.Text;

            }

            #region sql_SalesMaster

            SQL_new += @"
                INSERT INTO [Pos_SalesMaster]
                ([LocalSalesMasterID]
                ,[InvoiceNo]
                ,[WorkStationID]
                ,[SalesDate]
                ,[SalesReturnID]
                ,[CashSales]
                ,[CashSalesJournalDetailID]
                ,[DBBLAmount]
                ,[CityAmount]
                ,[VATPercentage]
                ,[VATAmount]
                ,[DiscountPercentage]
                ,[DiscountAmount]
                ,[RefundAmount]
                ,[SalesPerson]
                ,[Referrence]
                ,[Customer]
                ,[MobileNo]
                ,[CustomerName]
                ,[Note]
                ,[LocalJournalMasterID]
                ,[LocalTransactionMasterID]
                ,[LocalReturnTransactionMasterID]
                ,[ServerJournalMasterID]
                ,[ServerTransactionMasterID]
                ,[ServerReturnTransactionMasterID]
                ,[StatusID]
                ,[ExtraField1]
                ,[ExtraField2]
                ,[ExtraField3]
                ,[ExtraField4]
                ,[ExtraField5]
                ,[ExtraField6]
                ,[ExtraField7]
                ,[ExtraField8]
                ,[ExtraField9]
                ,[ExtraField10]
                ,[LocalCashAmountJournalDetailID]
          ,[LocalCard1AmountJournalDetailID]
          ,[LocalCard2AmountJournalDetailID]
          ,[LocalCard3AmountJournalDetailID]
          ,[ServerCashAmountJournalDetailID]
        ,[ServerCard1AmountJournalDetailID]
          ,[ServerCard2AmountJournalDetailID]
          ,[ServerCard3AmountJournalDetailID])
                VALUES
                (
                " + "0" + @"--<LocalSalesMasterID, int,>
                ," + "0" + @"--<InvoiceNo, int,>
                ," + ddlWorkStationSearch.SelectedValue + @"--<WorkStationID, int,>
                ,'" + (txtBackDatedSale.Text == DateTime.Now.ToString("dd MMM yyyy") ? DateTime.Now : DateTime.Parse(txtBackDatedSale.Text)) + @"'--<SalesDate, datetime,>
                ," + "0" + @"--<SalesReturnID, int,>
                ," + txtCashAmount.Text + @"--<CashSales, decimal(18,2),>
                ," + "0" + @"--<CashSalesJournalDetailID, int,>
                ," + "0" + @"--<DBBLAmount, decimal(18,2),>
                ," + "0" + @"--<CityAmount, decimal(18,2),>
                ," + "0" + @"--<VATPercentage, decimal(18,2),>
                ," + "0" + @"--<VATAmount, decimal(18,2),>
                ," + "0" + @"--<DiscountPercentage, decimal(18,2),>
                ," + "0" + @"--<DiscountAmount, decimal(18,2),>
                ," + decimal.Parse(txtRefundOrDue.Text).ToString("0.00") + @"--<RefundAmount, decimal(18,2),>
                ," + ddlSalesPerson.SelectedValue + @"--<SalesPerson, int,>
                ," + "0" + @"--<Referrence, int,>
                ," + (txtCustomerID.Text == "" ? "0" : txtCustomerID.Text) + @"--<Customer, int,>
                ,'" + txtContactNo.Text + @"'--<MobileNo, nvarchar(50),>
                ,'" + txtCustomerName.Text + @"'--<CustomerName, nvarchar(50),>
                ,'" + txtNote.Text + @"'--<Note, ntext,>
                ," + "0" + @"--<LocalJournalMasterID, int,>
                ," + "0" + @"--<LocalTransactionMasterID, int,>
                ," + "0" + @"--<LocalReturnTransactionMasterID, int,>
                ," + "0" + @"--<ServerJournalMasterID, int,>
                ," + "0" + @"--<ServerTransactionMasterID, int,>
                ," + "0" + @"--<ServerReturnTransactionMasterID, int,>
                ," + "0" + @"--<StatusID, int,>
                ,'" + decimal.Parse(txtCashAmount.Text).ToString("0.00") + @"'--<ExtraField1, nvarchar(256),>
                ,'" + decimal.Parse(txtCardAmount.Text).ToString("0.00") + @"'--<ExtraField2, nvarchar(256),>
                ,'" + ddlWorkStationSearch.SelectedItem.Text + @"'--<ExtraField3, nvarchar(256),>
                ,''--<ExtraField4, nvarchar(256),>
                ,'" + decimal.Parse(txtRefundOrDue.Text).ToString("0.00") + @"'--<ExtraField5, nvarchar(256),>
                ," + (isRetrun? "cast(@Pos_SalesReturnMasterID as nvarchar(256))" :"''") + @"--<ExtraField6, nvarchar(256),> updatedBy
                ,'" + PaymentGrid_cardPayment.ExtraField3 + @"'--<ExtraField7, nvarchar(256),> Issue From
                ,'" + PaymentGrid_cardPayment.ExtraField5 + @"'--<ExtraField8, nvarchar(256),> Card Amount
                ,'" + PaymentGrid_cardPayment.ExtraField2 + @"'--<ExtraField9, nvarchar(256),> Card Type
                ,'" + PaymentGrid_cardPayment.ExtraField1 + @"'--<ExtraField10, nvarchar(256),> Card No
                ,0,0,0,0,0,0,0,0);

                Set @Pos_SalesMasterID =SCOPE_IDENTITY();

                ";
            #endregion

        }

        foreach (GridViewRow gvr in gvPreview.Rows)
        {
            HiddenField hfPos_ProductID = (HiddenField)gvr.FindControl("hfPos_ProductID");
            TextBox txtQty = (TextBox)gvr.FindControl("txtQty");
            TextBox txtDiscountAmountTotal = (TextBox)gvr.FindControl("txtDiscountAmountTotal");
            TextBox txtVatGridTotal = (TextBox)gvr.FindControl("txtVatGridTotal");
            Label lblSubTotalSalePrice = (Label)gvr.FindControl("lblSubTotalSalePrice");
            HiddenField hfVatPercentageAlways = (HiddenField)gvr.FindControl("hfVatPercentageAlways");
            HiddenField hfTotalCostPerProduct = (HiddenField)gvr.FindControl("hfTotalCostPerProduct");
            Label lblStockSalePrice = (Label)gvr.FindControl("lblStockSalePrice");
            Label lblSalePrice = (Label)gvr.FindControl("lblSalePrice");

            if (txtQty.Text == "")
                continue;
            if (decimal.Parse(txtQty.Text) == 0)
                continue;

            #region sql_SalesDetails
           SQL_new += @"
            INSERT INTO [Pos_SalesDetail]
                       ([Pos_SalesMasterID]
                       ,[LocalSalesDetailID]
                       ,[RemoteSalesDetailID]
                       ,[ProductID]
                       ,[Quantity]
                       ,[WorkStationID]
                       ,[CostPrice]
                       ,[SalesPrice]
                       ,[DiscountPercentage]
                       ,[DiscountAmount]
                       ,[VATPercentage]
                       ,[VATAmount]
                       ,[LocalPos_TransactionMasterID]
                       ,[SererPos_TransactionMasterID]
                       ,[LocalTransactionID]
                       ,[ServerTransactionID]
                       ,[LocalPos_SalesMasterID]
                       ,[ServerPos_SalesMasterID]
                       ,[LocalFinishedGoodAssetJournalDetailID]
                       ,[LocalCostOfGoodsSoldJournalDetailID]
                       ,[LocalSalesRevinueJournalDetailID]
                       ,[LocalVATIncludingJournalDetailID]
                       ,[LocalVATExcludingJournalDetailID]
                       ,[LocalDiscountJournalDetailID]
                       ,[ServerFinishedGoodAssetJournalDetailID]
                       ,[ServerCostOfGoodsSoldJournalDetailID]
                       ,[ServerSalesRevinueJournalDetailID]
                       ,[ServerVATIncludingJournalDetailID]
                       ,[ServerVATExcludingJournalDetailID]
                       ,[ServerDiscountJournalDetailID]
                       ,[StatusID]
                       ,[ExtraField1]
                       ,[ExtraField2]
                       ,[ExtraField3]
                       ,[ExtraField4]
                       ,[ExtraField5]
                       ,[ExtraField6]
                       ,[ExtraField7]
                       ,[ExtraField8]
                       ,[ExtraField9]
                       ,[ExtraField10])
                 VALUES
                       (@Pos_SalesMasterID--Pos_SalesMasterID, int,>
                       ," + "0" + @"--LocalSalesDetailID, int,>
                       ," + "0" + @"--RemoteSalesDetailID, int,>
                       ," + hfPos_ProductID.Value + @"--ProductID, int,>
                       ," + txtQty.Text + @"--Quantity, int,>
                       ," + ddlWorkStationSearch.SelectedValue + @"--WorkStationID, int,>
                       ," + "0" + @"--CostPrice, decimal(18,2),>
                       ," + decimal.Parse(lblSalePrice.Text).ToString("0") + @"--SalesPrice, decimal(18,2),>
                       ," + decimal.Parse(hfVatPercentageAlways.Value).ToString("0") + @"--DiscountPercentage, decimal(18,2),>
                       ," + decimal.Parse(txtDiscountAmountTotal.Text).ToString("0") + @"--DiscountAmount, decimal(18,2),>
                       ," + "5" + @"--VATPercentage, decimal(18,2),>
                       ," + decimal.Parse(txtVatGridTotal.Text).ToString("0") + @"--VATAmount, decimal(18,2),>
                       ," + "0" + @"--LocalPos_TransactionMasterID, int,>
                       ," + "0" + @"--SererPos_TransactionMasterID, int,>
                       ," + "0" + @"--LocalTransactionID, int,>
                       ," + "0" + @"--ServerTransactionID, int,>
                       ," + "0" + @"--LocalPos_SalesMasterID, int,>
                       ," + "0" + @"--ServerPos_SalesMasterID, int,>
                       ," + "0" + @"--LocalFinishedGoodAssetJournalDetailID, int,>
                       ," + "0" + @"--LocalCostOfGoodsSoldJournalDetailID, int,>
                       ," + "0" + @"--LocalSalesRevinueJournalDetailID, int,>
                       ," + "0" + @"--LocalVATIncludingJournalDetailID, int,>
                       ," + "0" + @"--LocalVATExcludingJournalDetailID, int,>
                       ," + "0" + @"--LocalDiscountJournalDetailID, int,>
                       ," + "0" + @"--ServerFinishedGoodAssetJournalDetailID, int,>
                       ," + "0" + @"--ServerCostOfGoodsSoldJournalDetailID, int,>
                       ," + "0" + @"--ServerSalesRevinueJournalDetailID, int,>
                       ," + "0" + @"--ServerVATIncludingJournalDetailID, int,>
                       ," + "0" + @"--ServerVATExcludingJournalDetailID, int,>
                       ," + "0" + @"--ServerDiscountJournalDetailID, int,>
                       ," + "0" + @"--StatusID, int,>
                       ,'" + ddlRefference.SelectedValue + @"'----ExtraField1, nvarchar(256),>ddlRefference
                       ,'" + "" + @"'----ExtraField2, nvarchar(256),>
                       ,'" + "" + @"'----ExtraField3, nvarchar(256),>
                       ,'" + "" + @"'----ExtraField4, nvarchar(256),>
                       ,'" + "" + @"'----ExtraField5, nvarchar(256),>
                       ,'" + "" + @"'----ExtraField6, nvarchar(256),>
                       ,'" + "" + @"'----ExtraField7, nvarchar(256),>
                       ,'" + "" + @"'----ExtraField8, nvarchar(256),>
                       ,'" + "" + @"'----ExtraField9, nvarchar(256),>
                       ,'" + "" + @"'----ExtraField10, nvarchar(256),>
                       );

        ";
            #endregion

        }

        DataSet ds= CommonManager.SQLExec(SQL_new + @"
             select  @Pos_SalesMasterID ;");
        ExecuteTransactionNJournalEntry(ds.Tables[0].Rows[0][0].ToString());
    }
예제 #22
0
    public bool UpdatePos_Product(Pos_Product pos_Product)
    {
        using (SqlConnection connection = new SqlConnection(this.ConnectionString))
        {
            SqlCommand cmd = new SqlCommand("GP_UpdatePos_Product", connection);
            cmd.CommandType = CommandType.StoredProcedure;
            cmd.Parameters.Add("@Pos_ProductID", SqlDbType.Int).Value = pos_Product.Pos_ProductID;
            cmd.Parameters.Add("@ProductID", SqlDbType.Int).Value = pos_Product.ProductID;
            cmd.Parameters.Add("@ReferenceID", SqlDbType.Int).Value = pos_Product.ReferenceID;
            cmd.Parameters.Add("@Pos_ProductTypeID", SqlDbType.Int).Value = pos_Product.Pos_ProductTypeID;
            cmd.Parameters.Add("@Inv_UtilizationDetailsIDs", SqlDbType.NVarChar).Value = pos_Product.Inv_UtilizationDetailsIDs;
            cmd.Parameters.Add("@ProductStatusID", SqlDbType.Int).Value = pos_Product.ProductStatusID;
            cmd.Parameters.Add("@ProductName", SqlDbType.NVarChar).Value = pos_Product.ProductName;
            cmd.Parameters.Add("@DesignCode", SqlDbType.NVarChar).Value = pos_Product.DesignCode;
            cmd.Parameters.Add("@Pos_SizeID", SqlDbType.Int).Value = pos_Product.Pos_SizeID;
            cmd.Parameters.Add("@Pos_BrandID", SqlDbType.Int).Value = pos_Product.Pos_BrandID;
            cmd.Parameters.Add("@Inv_QuantityUnitID", SqlDbType.Int).Value = pos_Product.Inv_QuantityUnitID;
            cmd.Parameters.Add("@FabricsCost", SqlDbType.Decimal).Value = pos_Product.FabricsCost;
            cmd.Parameters.Add("@AccesoriesCost", SqlDbType.Decimal).Value = pos_Product.AccesoriesCost;
            cmd.Parameters.Add("@Overhead", SqlDbType.Decimal).Value = pos_Product.Overhead;
            cmd.Parameters.Add("@OthersCost", SqlDbType.Decimal).Value = pos_Product.OthersCost;
            cmd.Parameters.Add("@PurchasePrice", SqlDbType.Decimal).Value = pos_Product.PurchasePrice;
            cmd.Parameters.Add("@SalePrice", SqlDbType.Decimal).Value = pos_Product.SalePrice;
            cmd.Parameters.Add("@OldSalePrice", SqlDbType.Decimal).Value = pos_Product.OldSalePrice;
            cmd.Parameters.Add("@Note", SqlDbType.NText).Value = pos_Product.Note;
            cmd.Parameters.Add("@BarCode", SqlDbType.NVarChar).Value = pos_Product.BarCode;
            cmd.Parameters.Add("@Pos_ColorID", SqlDbType.Int).Value = pos_Product.Pos_ColorID;
            cmd.Parameters.Add("@Pos_FabricsTypeID", SqlDbType.Int).Value = pos_Product.Pos_FabricsTypeID;
            cmd.Parameters.Add("@StyleCode", SqlDbType.NVarChar).Value = pos_Product.StyleCode;
            cmd.Parameters.Add("@Pic1", SqlDbType.NVarChar).Value = pos_Product.Pic1;
            cmd.Parameters.Add("@Pic2", SqlDbType.NVarChar).Value = pos_Product.Pic2;
            cmd.Parameters.Add("@Pic3", SqlDbType.NVarChar).Value = pos_Product.Pic3;
            cmd.Parameters.Add("@VatPercentage", SqlDbType.Decimal).Value = pos_Product.VatPercentage;
            cmd.Parameters.Add("@IsVatExclusive", SqlDbType.Bit).Value = pos_Product.IsVatExclusive;
            cmd.Parameters.Add("@DiscountPercentage", SqlDbType.Decimal).Value = pos_Product.DiscountPercentage;
            cmd.Parameters.Add("@DiscountAmount", SqlDbType.Decimal).Value = pos_Product.DiscountAmount;
            cmd.Parameters.Add("@FabricsNo", SqlDbType.NVarChar).Value = pos_Product.FabricsNo;
            cmd.Parameters.Add("@ExtraField1", SqlDbType.NVarChar).Value = pos_Product.ExtraField1;
            cmd.Parameters.Add("@ExtraField2", SqlDbType.NVarChar).Value = pos_Product.ExtraField2;
            cmd.Parameters.Add("@ExtraField3", SqlDbType.NVarChar).Value = pos_Product.ExtraField3;
            cmd.Parameters.Add("@ExtraField4", SqlDbType.NVarChar).Value = pos_Product.ExtraField4;
            cmd.Parameters.Add("@ExtraField5", SqlDbType.NVarChar).Value = pos_Product.ExtraField5;
            cmd.Parameters.Add("@ExtraField6", SqlDbType.NVarChar).Value = pos_Product.ExtraField6;
            cmd.Parameters.Add("@ExtraField7", SqlDbType.NVarChar).Value = pos_Product.ExtraField7;
            cmd.Parameters.Add("@ExtraField8", SqlDbType.NVarChar).Value = pos_Product.ExtraField8;
            cmd.Parameters.Add("@ExtraField9", SqlDbType.NVarChar).Value = pos_Product.ExtraField9;
            cmd.Parameters.Add("@ExtraField10", SqlDbType.NVarChar).Value = pos_Product.ExtraField10;
            cmd.Parameters.Add("@AddedBy", SqlDbType.Int).Value = pos_Product.AddedBy;
            cmd.Parameters.Add("@AddedDate", SqlDbType.DateTime).Value = pos_Product.AddedDate;
            cmd.Parameters.Add("@UpdatedBy", SqlDbType.Int).Value = pos_Product.UpdatedBy;
            cmd.Parameters.Add("@UpdatedDate", SqlDbType.DateTime).Value = pos_Product.UpdatedDate;
            cmd.Parameters.Add("@RowStatusID", SqlDbType.Int).Value = pos_Product.RowStatusID;
            connection.Open();

            int result = cmd.ExecuteNonQuery();
            return result == 1;
        }
    }
예제 #23
0
파일: Sales.aspx.cs 프로젝트: anam/gp-HO
    protected void btnAddToPreview_Click(object sender, EventArgs e)
    {
        List<Pos_Product> takenFromSearchProduct = new List<Pos_Product>();

        foreach (GridViewRow gvr in gvPos_Product.Rows)
        {
            Pos_Product prod = new Pos_Product();

            HiddenField hfPos_ProductID = (HiddenField)gvr.FindControl("hfPos_ProductID");

            Label lblProductName = (Label)gvr.FindControl("lblProductName");
            Label lblBarCode = (Label)gvr.FindControl("lblBarCode");
            Label lblSizeName = (Label)gvr.FindControl("lblSizeName");
            Label lblColorName = (Label)gvr.FindControl("lblColorName");
            Label lblProductStatusName = (Label)gvr.FindControl("lblProductStatusName");
            Label lblStock = (Label)gvr.FindControl("lblStock");
            Label lblSalePrice = (Label)gvr.FindControl("lblSalePrice");
            Label lblStockSalePrice = (Label)gvr.FindControl("lblStockSalePrice");

            TextBox txtQty = (TextBox)gvr.FindControl("txtQty");
            TextBox txtVatGrid = (TextBox)gvr.FindControl("txtVatGrid");
            TextBox txtDiscountGrid = (TextBox)gvr.FindControl("txtDiscountGrid");
            TextBox txtDiscountAmountGrid = (TextBox)gvr.FindControl("txtDiscountAmountGrid");
            HiddenField hfVatPercentageAlways = (HiddenField)gvr.FindControl("hfVatPercentageAlways");
            HiddenField hfTotalCostPerProduct = (HiddenField)gvr.FindControl("hfTotalCostPerProduct");

            prod.Pos_ProductID = int.Parse(hfPos_ProductID.Value);
            prod.ProductName = lblProductName.Text;
            prod.BarCode = lblBarCode.Text;
            prod.ExtraField1 = txtQty.Text;
            prod.ExtraField10 = lblSizeName.Text;
            prod.ExtraField2 = lblColorName.Text;
            prod.ExtraField3 = lblProductStatusName.Text;
            prod.ExtraField4 = lblStock.Text;
            decimal acctualSalesAmount = decimal.Parse(lblSalePrice.Text);
            decimal acctualSalesAmountTotal = decimal.Parse(lblSalePrice.Text) * decimal.Parse(txtQty.Text);

            prod.ExtraField5 = (acctualSalesAmount).ToString("0,0");
            prod.ExtraField6 = (decimal.Parse(prod.ExtraField5) * decimal.Parse(txtQty.Text)).ToString("0,0");
            prod.DiscountAmount = decimal.Parse(txtDiscountAmountGrid.Text) != 0 ? (decimal.Parse(txtDiscountAmountGrid.Text) * decimal.Parse(txtQty.Text)) : ((decimal.Parse(prod.ExtraField6)) * (decimal.Parse(txtDiscountGrid.Text) / 100));
            prod.ExtraField8 = (acctualSalesAmountTotal * (decimal.Parse(hfVatPercentageAlways.Value)/100)).ToString("0,0");//  (acctualSalesAmountTotal * decimal.Parse("0.05")).ToString("0,0");// decimal.Parse(txtVatGrid.Text) == 0 ? "0.00" : ((acctualSalesAmountTotal) * (decimal.Parse(txtVatGrid.Text) / 100)).ToString("0,0");
            prod.ExtraField9 = (decimal.Parse(prod.ExtraField6) - prod.DiscountAmount + decimal.Parse(prod.ExtraField8)).ToString("0,0");
            prod.ExtraField7 = "0";//not fund
            prod.AccesoriesCost = decimal.Parse(prod.ExtraField8);
            prod.FabricsCost = prod.DiscountAmount;
            //rewrite
            prod.ExtraField8 = txtVatGrid.Text;
            prod.DiscountAmount = decimal.Parse(txtDiscountAmountGrid.Text);
            prod.DiscountPercentage = decimal.Parse(txtDiscountGrid.Text);

            if (decimal.Parse(lblStock.Text) < decimal.Parse(txtQty.Text))
            {
                showAlartMessage("For "+lblBarCode.Text+"the Qty is more than the stock");
                continue;
            }

            prod.VatPercentage = decimal.Parse(hfVatPercentageAlways.Value);
            prod.OthersCost = decimal.Parse(hfTotalCostPerProduct.Value); //total cost
            if (txtQty.Text != "0")
            takenFromSearchProduct.Add(prod);
        }

        List<Pos_Product> takenFromPreviewProduct = new List<Pos_Product>();

        foreach (GridViewRow gvr in gvPreview.Rows)
        {
            Pos_Product prod = new Pos_Product();

            HiddenField hfPos_ProductID = (HiddenField)gvr.FindControl("hfPos_ProductID");

            Label lblProductName = (Label)gvr.FindControl("lblProductName");
            Label lblBarCode = (Label)gvr.FindControl("lblBarCode");
            Label lblSizeName = (Label)gvr.FindControl("lblSizeName");
            Label lblColorName = (Label)gvr.FindControl("lblColorName");
            Label lblProductStatusName = (Label)gvr.FindControl("lblProductStatusName");
            Label lblStock = (Label)gvr.FindControl("lblStock");
            Label lblSalePrice = (Label)gvr.FindControl("lblSalePrice");
            Label lblStockSalePrice = (Label)gvr.FindControl("lblStockSalePrice");

            TextBox txtQty = (TextBox)gvr.FindControl("txtQty");
            TextBox txtVatGrid = (TextBox)gvr.FindControl("txtVatGrid");
            TextBox txtDiscountGrid = (TextBox)gvr.FindControl("txtDiscountGrid");
            TextBox txtDiscountAmountGrid = (TextBox)gvr.FindControl("txtDiscountAmountGrid");
            HiddenField hfVatPercentageAlways = (HiddenField)gvr.FindControl("hfVatPercentageAlways");
            HiddenField hfTotalCostPerProduct = (HiddenField)gvr.FindControl("hfTotalCostPerProduct");

            prod.Pos_ProductID = int.Parse(hfPos_ProductID.Value);
            prod.ProductName = lblProductName.Text;
            prod.BarCode = lblBarCode.Text;
            prod.ExtraField1 = txtQty.Text;
            prod.ExtraField10 = lblSizeName.Text;
            prod.ExtraField2 = lblColorName.Text;
            prod.ExtraField3 = lblProductStatusName.Text;
            prod.ExtraField4 = lblStock.Text;
            decimal acctualSalesAmount = decimal.Parse(lblSalePrice.Text);
            decimal acctualSalesAmountTotal = decimal.Parse(lblSalePrice.Text) * decimal.Parse(txtQty.Text);

            prod.ExtraField5 = (acctualSalesAmount).ToString("0,0");
            prod.ExtraField6 = (decimal.Parse(prod.ExtraField5) * decimal.Parse(txtQty.Text)).ToString("0,0");
            prod.DiscountAmount = decimal.Parse(txtDiscountAmountGrid.Text) != 0 ? (decimal.Parse(txtDiscountAmountGrid.Text) * decimal.Parse(txtQty.Text)) : ((decimal.Parse(prod.ExtraField6)) * (decimal.Parse(txtDiscountGrid.Text) / 100));
            prod.ExtraField8 = (acctualSalesAmountTotal * decimal.Parse("0.05")).ToString("0,0");// decimal.Parse(txtVatGrid.Text) == 0 ? "0.00" : ((acctualSalesAmountTotal) * (decimal.Parse(txtVatGrid.Text) / 100)).ToString("0,0");
            prod.ExtraField9 = (decimal.Parse(prod.ExtraField6) - prod.DiscountAmount + decimal.Parse(prod.ExtraField8)).ToString("0,0");

            prod.ExtraField7 = "0";//not fund

            prod.AccesoriesCost = decimal.Parse(prod.ExtraField8);
            prod.FabricsCost = prod.DiscountAmount;

            //Rewrite
            prod.ExtraField8 = txtVatGrid.Text;
            prod.DiscountAmount = decimal.Parse(txtDiscountAmountGrid.Text);
            prod.DiscountPercentage = decimal.Parse(txtDiscountGrid.Text);

            prod.VatPercentage = decimal.Parse(hfVatPercentageAlways.Value);
            prod.OthersCost = decimal.Parse(hfTotalCostPerProduct.Value); //total cost

            if (txtQty.Text!="0")
                takenFromPreviewProduct.Add(prod);
        }

        foreach (Pos_Product previewProd in takenFromPreviewProduct)
        {
            foreach (Pos_Product searchProd in takenFromSearchProduct)
            {
                if (searchProd.Pos_ProductID == previewProd.Pos_ProductID)
                {
                    previewProd.ExtraField6 = searchProd.ExtraField6;
                    previewProd.DiscountAmount = searchProd.DiscountAmount;
                    previewProd.ExtraField8 = searchProd.ExtraField8;
                    previewProd.ExtraField9 = searchProd.ExtraField9;
                    //previewProd.AccesoriesCost = searchProd.AccesoriesCost;
                    previewProd.FabricsCost = decimal.Parse(searchProd.FabricsCost.ToString("0"));

                    previewProd.VatPercentage = searchProd.VatPercentage;
                    previewProd.OthersCost = searchProd.OthersCost;

                    searchProd.ExtraField7 = "1";
                    if (int.Parse(previewProd.ExtraField4) >= int.Parse(previewProd.ExtraField1))
                    {
                        previewProd.AccesoriesCost = ((previewProd.AccesoriesCost / int.Parse(previewProd.ExtraField1)) * (int.Parse(previewProd.ExtraField1) + 1));
                        previewProd.ExtraField1 = (int.Parse(previewProd.ExtraField1) + 1).ToString();
                    }
                }
            }
        }

        foreach (Pos_Product searchProd in takenFromSearchProduct)
        {
            if (searchProd.ExtraField7 == "0")
            {
                takenFromPreviewProduct.Add(searchProd);
            }
        }

        //foreach (Pos_Product prod in takenFromPreviewProduct)
        //{
        //    prod.ExtraField6 = (decimal.Parse(prod.ExtraField5) * decimal.Parse(prod.ExtraField1)).ToString("0,0.00");

        //}

        gvPreview.DataSource = takenFromPreviewProduct;
        gvPreview.DataBind();

        decimal totalStock = 0;
        decimal qty = 0;
        decimal totalAmount = 0;
        decimal SubtotalAmount = 0;
        decimal discountSum = 0;
        decimal vatSum = 0;
        foreach (Pos_Product prod in takenFromPreviewProduct)
        {
            totalAmount += decimal.Parse(prod.ExtraField6);
            SubtotalAmount += decimal.Parse(prod.ExtraField9);
            totalStock += decimal.Parse(prod.ExtraField4);
            qty += decimal.Parse(prod.ExtraField1);
            vatSum += prod.AccesoriesCost;
            discountSum += prod.FabricsCost;
        }

        try
        {
            ((Label)gvPreview.FooterRow.FindControl("lblStockFooter")).Text = totalStock.ToString("0,0");
            ((Label)gvPreview.FooterRow.FindControl("lblStockSalePriceFooter")).Text = totalAmount.ToString("0,0.00");
            ((Label)gvPreview.FooterRow.FindControl("lblQtyFooter")).Text = qty.ToString("0,0");
            ((Label)gvPreview.FooterRow.FindControl("lblSubTotalSalePriceFooter")).Text = SubtotalAmount.ToString("0,0.00");
            ((Label)gvPreview.FooterRow.FindControl("lblDiscountAmountTotalFooter")).Text = discountSum.ToString("0,0.00");
            ((Label)gvPreview.FooterRow.FindControl("lblVatGridTotalFooter")).Text = vatSum.ToString("0,0.00");
        }
        catch (Exception ex)
        { }
        txtSubTotal.Text = totalAmount.ToString("0,0.00");
        txtVat.Text = vatSum.ToString("0,0.00");
        txtDiscount.Text = discountSum.ToString("0,0.00");

        lblTotalQty.Text = qty.ToString("0,0");

        txtCashAmount_TextChanged(this, new EventArgs());
        btnApplyDiscount_Click(this, new EventArgs());
    }