Пример #1
0
    private void CountDeliveryAmount()
    {
        foreach (DataListItem item in DataList1.Items)
        {
            Label lblcartid = (Label)item.FindControl("lblCartid");
            string ChefID = con.singlecell("select Chef_ID from CartMaster where Cart_ID='" + lblcartid.Text + "'");
            string ChefZipCode = con.singlecell("Select PinCode from ChefPersonalDetail Where Chef_ID='" + ChefID + "'");
            string Destination = lblpincode.Text;
            
            //string consumeraddresss = objcheck.get_User_Address(Session["Consumer_ID"].ToString(),false,true,addressid);
            //string chefaddress = objcheck.get_User_Address(ChefID,true,true,null);

            if (con.check_data("Select * from DeliveryCount where Cart_ID='" + lblcartid.Text + "'"))
            {
            }
            else
            {
             commonfunctions cf = new commonfunctions();
                Dictionary<string, string> fromvalues = new Dictionary<string, string>();
                //fromvalues = cf.CalculateResult(chefaddress, consumeraddresss);
                fromvalues = cf.CalculateResult(ChefZipCode, Destination);
                lblshippingcharge.Text = fromvalues["charges"];

                string shippingcarge = fromvalues["charges"];

                    int shippingcharge = int.Parse(fromvalues["charges"]);
                    SqlParameter[] p1 = new SqlParameter[3];
                    p1[0] = new SqlParameter("@CartID", lblcartid.Text);
                    p1[1] = new SqlParameter("@Mode", 3);
                    p1[2] = new SqlParameter("@DeliveryAmt", shippingcharge);

                    con1.Ins_Upd_Del("SP_ConsumerCart_Edit", p1);
                   // con.insert_data("insert into DeliveryCount values('" + ChefID + "','" + fromvalues["distancecount"] + "','" + lblcartid.Text + "','" + shippingcharge.ToString() + "')");
                    con.insert_data("insert into DeliveryCount values('" + Session["Consumer_ID"] + "','" + fromvalues["distancecount"] + "','" + lblcartid.Text + "','" + shippingcharge.ToString() + "')");
               
            }

        }
        string totdelAmt = con.singlecell("Select Sum(Amount) from DeliveryCount where Chef_ID='" + Session["Consumer_ID"] + "' and Amount!='-1'");
        con.delete_data("delete from DeliveryCount where Chef_ID='" + Session["Consumer_ID"] + "'");
        lblshippingcharge.Text = totdelAmt;
    }