Esempio n. 1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                DropDownDepartment.DataSource = DAL.GetDepartments();
                DropDownDepartment.DataBind();

                DropDownListManager.DataSource = DAL.GetEmployeeIdAndName();
                DropDownListManager.DataBind();
            }
        }
Esempio n. 2
0
    public void clear()
    {
        hfPurchaseId.Value = "";
        txtQuantity.Text   = txtOthers.Text = txtDate.Text = txtAmount.Text = TextBox1.Text = "";
        DropDownProduct.ClearSelection();
        DropDownSupplier.ClearSelection();
        DropDownDepartment.ClearSelection();

        lblerrormessage.Text = lblsuccessmassage.Text = "";
        btnsave.Text         = "Save";
        btndelete.Enabled    = true;
    }
Esempio n. 3
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                DropDownDepartment.DataSource = DAL.GetDepartments();
                DropDownDepartment.DataBind();

                DropDownListManager.DataSource = DAL.GetEmployeeIdAndName();
                DropDownListManager.DataBind();
                DropDownListManager.Items.Add(new ListItem("--Select--", "0"));
                DropDownListManager.SelectedValue = "0";
            }
        }
        /// <summary>
        /// department dropdownlist value
        /// </summary>
        /// <param name="account"></param>
        /// <param name="factory"></param>
        /// <returns></returns>
        public List <DropDownDepartment> GetDepartmentByAccount(string account, string factory)
        {
            List <DropDownDepartment> _DropDownDepartmentList = new List <DropDownDepartment>();
            var results = this._budget_LoginUploadReportService.GetAll().Join(this._budget_DepartmentReportService.GetAll(),
                                                                              LoginUploadReport => new { LoginUploadReport.DepartmentId, LoginUploadReport.Factory },
                                                                              DepartmentReport => new { DepartmentReport.DepartmentId, DepartmentReport.Factory },
                                                                              (LoginUploadReport, DepartmentReport) => new
            {
                LoginUploadReport,
                DepartmentReport
            }).Where(x => x.LoginUploadReport.Factory == factory && x.LoginUploadReport.Account == account).ToList();

            foreach (var r in results)
            {
                DropDownDepartment _DropDownDepartment = new DropDownDepartment();
                _DropDownDepartment.DepartmentId   = r.LoginUploadReport.DepartmentId;
                _DropDownDepartment.DepartmentName = r.DepartmentReport.DepartmentName;
                _DropDownDepartmentList.Add(_DropDownDepartment);
            }
            return(_DropDownDepartmentList);
        }
Esempio n. 5
0
    protected void btnsave_Click(object sender, EventArgs e)
    {
        //Console.Write(DropDownProduct.SelectedValue);
        //Console.Write(DropDownProduct.SelectedItem.Text);
        //Console.WriteLine(DropDownSupplier.SelectedValue);
        //Console.WriteLine(DropDownSupplier.SelectedItem.Text);


        if (sqlcon.State == ConnectionState.Closed)
        {
            sqlcon.Open();
        }
        //SqlCommand sqlcmd = new SqlCommand("PurchaseCreateOrUpdate", sqlcon);
        //sqlcmd.CommandType = CommandType.StoredProcedure;
        //sqlcmd.Parameters.AddWithValue("@PurchaseId", hfPurchaseId.Value == "" ? 0 : Convert.ToInt32(hfPurchaseId.Value));
        //sqlcmd.Parameters.AddWithValue("@ProductId", Convert.ToInt32(DropDownProduct.SelectedValue));
        //sqlcmd.Parameters.AddWithValue("@SupplierId", Convert.ToInt32(DropDownSupplier.SelectedValue));
        //sqlcmd.Parameters.AddWithValue("@Quantity", Convert.ToInt32(txtQuantity.Text.Trim()));
        //sqlcmd.Parameters.AddWithValue("@DateOfPurchase", Convert.ToInt32(txtDate.Text.Trim()));
        //sqlcmd.Parameters.AddWithValue("@Others", txtOthers.Text);
        //sqlcmd.ExecuteNonQuery();
        //sqlcon.Close();
        //string PurchaseId = hfPurchaseId.Value;

        ///here productId is DepartmentId


        SqlCommand cmd = new SqlCommand("Insert into Purchase values(@PurchaseId,@ProductId,@SupplierId,@Quantity,@TotalAmount,@DateOfPurchase,@Others)", sqlcon);

        cmd.Parameters.AddWithValue("@PurchaseId", DropDownDepartment.SelectedValue);
        cmd.Parameters.AddWithValue("@ProductId", DropDownProduct.SelectedItem.Text);
        cmd.Parameters.AddWithValue("@SupplierId", DropDownSupplier.SelectedItem.Text);
        cmd.Parameters.AddWithValue("@Quantity", txtQuantity.Text.Trim());
        cmd.Parameters.AddWithValue("@TotalAmount", txtAmount.Text.Trim());
        cmd.Parameters.AddWithValue("@DateOfPurchase", txtDate.Text.Trim());
        cmd.Parameters.AddWithValue("@Others", txtOthers.Text.Trim());

        int i = cmd.ExecuteNonQuery();

        sqlcon.Close();
        string PurchaseId = hfPurchaseId.Value;

        if (i > 0)
        {
            lblsuccessmassage.Text = "Saved Successfully";
        }
        else
        {
            lblsuccessmassage.Text = "Updated Successfully";

            FillGridView();


            clear();
            DropDownProduct.ClearSelection();
            DropDownSupplier.ClearSelection();
            DropDownDepartment.ClearSelection();
        }
        //void FillGridView()
        //{
        //    if (sqlcon.State == ConnectionState.Closed)
        //        sqlcon.Open();
        //    string pronamequery = "Select Purchase.PurchaseID,Product.ProductName,Supplier.CompanyName,Purchase.Quantity,Purchase.Others from purchase INNER JOIN Product on Product.ProductId = Purchase.PurchaseId INNER JOIN Supplier on Supplier.SupplierId = Purchase.PurchaseId";
        //    SqlCommand scmd = new SqlCommand(pronamequery, sqlcon);
        //    SqlDataAdapter sda = new SqlDataAdapter(scmd);
        //    DataTable dt = new DataTable();
        //    sda.Fill(dt);
        //    sqlcon.Close();
        //    purchaseGrid.DataSource = dt;
        //    purchaseGrid.DataBind();

        //SqlDataAdapter sqlDa = new SqlDataAdapter("ViewPurchaseGrid", sqlcon);
        //sqlDa.SelectCommand.CommandType = CommandType.StoredProcedure;
        //DataTable dtbl = new DataTable();
        //sqlDa.Fill(dtbl);
        //sqlcon.Close();
        //purchaseGrid.DataSource = dtbl;
        //purchaseGrid.DataBind();
    }