コード例 #1
0
        private bool saveData()
        {
            bool   blnResult    = false;
            string strUpdatedBy = string.Empty;

            strUpdatedBy = Session["username"].ToString();
            CheckBox      chkSelect;
            Label         lblrecv_item_code        = null;
            Label         lblrecv_item_name        = null;
            AwNumeric     txtrecv_item_rate        = null;
            CheckBox      chkRecv_item_is_director = null;
            var           oDeduct       = new cDeduct();
            Deduct_detail deduct_detail = null;

            try
            {
                foreach (GridViewRow gvRow in GridView1.Rows)
                {
                    chkSelect = (CheckBox)gvRow.FindControl("chkSelect");
                    var select = Request.Form[chkSelect.UniqueID];
                    if (select != null && select == "on")
                    {
                        lblrecv_item_code        = (Label)gvRow.FindControl("lblrecv_item_code");
                        lblrecv_item_name        = (Label)gvRow.FindControl("lblrecv_item_name");
                        txtrecv_item_rate        = (AwNumeric)gvRow.FindControl("txtrecv_item_rate");
                        chkRecv_item_is_director = (CheckBox)gvRow.FindControl("chkRecv_item_is_director");
                        var recv_item_rate = decimal.Parse(txtrecv_item_rate.Value.ToString());
                        deduct_detail = new Deduct_detail
                        {
                            deduct_doc_no           = ViewState["deduct_doc"].ToString(),
                            recv_item_code          = lblrecv_item_code.Text,
                            recv_item_rate          = recv_item_rate,
                            deduct_item_amount      = decimal.Parse(ViewState["recv_total_amount"].ToString()) * recv_item_rate / 100,
                            deduct_item_is_director = chkRecv_item_is_director.Checked,
                            c_created_by            = strUpdatedBy
                        };
                        oDeduct.SP_DEDUCT_DETAIL_INS(deduct_detail);
                    }
                    blnResult = true;
                }
            }
            catch (Exception ex)
            {
                lblError.Text = ex.Message;
            }
            finally
            {
                oDeduct.Dispose();
            }
            return(blnResult);
        }
コード例 #2
0
        private bool saveDataDetail()
        {
            bool               blnResult                   = false;
            string             strScript                   = string.Empty;
            cBudget_money      oBudget_money               = new cBudget_money();
            HiddenField        hddbudget_money_major_id    = null;
            AwNumeric          txtbudget_money_major_plan  = null;
            AwNumeric          txtbudget_money_major_plan2 = null;
            AwNumeric          txtbudget_money_major_plan3 = null;
            Budget_money_major budget_money_major          = null;

            try
            {
                #region set Data
                //GridViewRow item = (GridViewRow)GridView1.Controls[0].Controls[0];
                for (var index = 0; index < GridViewMajor.Rows.Count; index++)
                {
                    hddbudget_money_major_id    = (HiddenField)GridViewMajor.Rows[index].FindControl("hddbudget_money_major_id");
                    txtbudget_money_major_plan  = (AwNumeric)GridViewMajor.Rows[index].FindControl("txtbudget_money_major_plan");
                    txtbudget_money_major_plan2 = (AwNumeric)GridViewMajor.Rows[index].FindControl("txtbudget_money_major_plan2");
                    txtbudget_money_major_plan3 = (AwNumeric)GridViewMajor.Rows[index].FindControl("txtbudget_money_major_plan3");
                    budget_money_major          = new Budget_money_major
                    {
                        budget_money_major_id    = long.Parse(hddbudget_money_major_id.Value),
                        budget_money_major_plan  = decimal.Parse(txtbudget_money_major_plan.Value.ToString()),
                        budget_money_major_plan2 = decimal.Parse(txtbudget_money_major_plan2.Value.ToString()),
                        budget_money_major_plan3 = decimal.Parse(txtbudget_money_major_plan3.Value.ToString()),
                        c_updated_by             = Session["username"].ToString()
                    };
                    oBudget_money.SP_BUDGET_MONEY_MAJOR_UPD(budget_money_major);
                }
                blnResult = true;
            }
            catch (Exception ex)
            {
                if (ex.Message.Contains("duplicate key"))
                {
                    MsgBox("ข้อมูลซ้ำโปรดตรวจสอบ");
                }
                else
                {
                    lblError.Text = ex.Message.ToString();
                }
            }
            finally
            {
                oBudget_money.Dispose();
            }
            return(blnResult);
        }
コード例 #3
0
        private bool saveDataDetail()
        {
            bool               blnResult                = false;
            string             strScript                = string.Empty;
            cBudget_open       oBudget_open             = new cBudget_open();
            HiddenField        hddbudget_open_detail_id = null;
            TextBox            txtmaterial_detail       = null;
            AwNumeric          txtopen_detail_amount    = null;
            Budget_open_detail budget_open_detail       = null;

            try
            {
                for (var index = 0; index < GridView1.Rows.Count; index++)
                {
                    hddbudget_open_detail_id = (HiddenField)GridView1.Rows[index].FindControl("hddbudget_open_detail_id");
                    txtmaterial_detail       = (TextBox)GridView1.Rows[index].FindControl("txtmaterial_detail");
                    txtopen_detail_amount    = (AwNumeric)GridView1.Rows[index].FindControl("txtopen_detail_amount");
                    if (!string.IsNullOrEmpty(hddbudget_open_detail_id.Value))
                    {
                        budget_open_detail = new Budget_open_detail
                        {
                            budget_open_doc           = ViewState["budget_open_doc"].ToString(),
                            budget_open_detail_id     = long.Parse(hddbudget_open_detail_id.Value),
                            budget_open_detail_amount = decimal.Parse(txtopen_detail_amount.Value.ToString()),
                            material_detail           = txtmaterial_detail.Text,
                            c_updated_by = Session["username"].ToString()
                        };
                        oBudget_open.SP_BUDGET_OPEN_DETAIL_UPD(budget_open_detail);
                    }
                }
                blnResult = true;
            }
            catch (Exception ex)
            {
                if (ex.Message.Contains("duplicate key"))
                {
                    MsgBox("ข้อมูลซ้ำโปรดตรวจสอบ");
                }
                else
                {
                    lblError.Text = ex.Message.ToString();
                }
            }
            finally
            {
                oBudget_open.Dispose();
            }
            return(blnResult);
        }
コード例 #4
0
        public void InstantiateIn(System.Web.UI.Control container)
        {
            // Create the content for the different row types.
            switch (templateType)
            {
            case DataControlRowType.Header:
                // Create the controls to put in the header
                // section and set their properties.
                Literal lc = new Literal();
                lc.Text = "<b>" + columnName + "</b>";

                // Add the controls to the Controls collection
                // of the container.
                container.Controls.Add(lc);
                break;

            case DataControlRowType.DataRow:
                // Create the controls to put in a data row
                // section and set their properties.
                AwNumeric textbox = new AwNumeric
                {
                    Width   = System.Web.UI.WebControls.Unit.Percentage(90),
                    ID      = columnName,
                    Visible = false
                };
                container.Controls.Add(textbox);
                HiddenField hidden = new HiddenField
                {
                    ID = columnName.Replace("txt", "hdd")
                };
                container.Controls.Add(hidden);
                break;

            // Insert cases to create the content for the other
            // row types, if desired.

            default:
                // Insert code to handle unexpected values.
                break;
            }
        }
コード例 #5
0
        protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            if (e.Row.RowType.Equals(DataControlRowType.Header))
            {
                mTotalall = 0;
                //ImageButton imgAdd = (ImageButton)e.Row.FindControl("imgAdd");
                //imgAdd.ImageUrl = ((DataSet)Application["xmlconfig"]).Tables["imgGridAdd"].Rows[0]["img"].ToString();
                //imgAdd.Attributes.Add("title", ((DataSet)Application["xmlconfig"]).Tables["imgGridAdd"].Rows[0]["title"].ToString());
                //imgAdd.Attributes.Add("onclick", "OpenPopUp('800px','350px','93%','เพิ่มข้อมูลสมุดเงินรับ','item_acc_save_item_control.aspx?item_acc_doc=" + txtitem_acc_doc.Text) ;

                for (int iCol = 0; iCol < e.Row.Cells.Count; iCol++)
                {
                    e.Row.Cells[iCol].Attributes.Add("class", "table_h");
                    e.Row.Cells[iCol].Wrap = false;
                }
                ViewState["item_acc_amount"] = "0";
                ViewState["item_acc_tax"]    = "0";
                ViewState["item_acc_total"]  = "0";
            }
            else if (e.Row.RowType.Equals(DataControlRowType.DataRow) || e.Row.RowState.Equals(DataControlRowState.Alternate))
            {
                #region Set datagrid row color
                string strEvenColor, strOddColor, strMouseOverColor;
                strEvenColor      = ((DataSet)Application["xmlconfig"]).Tables["colorDataGridRow"].Rows[0]["Even"].ToString();
                strOddColor       = ((DataSet)Application["xmlconfig"]).Tables["colorDataGridRow"].Rows[0]["Odd"].ToString();
                strMouseOverColor = ((DataSet)Application["xmlconfig"]).Tables["colorDataGridRow"].Rows[0]["MouseOver"].ToString();

                e.Row.Style.Add("valign", "top");
                e.Row.Style.Add("cursor", "hand");
                e.Row.Attributes.Add("onMouseOver", "this.style.backgroundColor='" + strMouseOverColor + "'");

                if (e.Row.RowState.Equals(DataControlRowState.Alternate))
                {
                    e.Row.Attributes.Add("bgcolor", strOddColor);
                    e.Row.Attributes.Add("onMouseOut", "this.style.backgroundColor='" + strOddColor + "'");
                }
                else
                {
                    e.Row.Attributes.Add("bgcolor", strEvenColor);
                    e.Row.Attributes.Add("onMouseOut", "this.style.backgroundColor='" + strEvenColor + "'");
                }
                #endregion
                Label lblNo = (Label)e.Row.FindControl("lblNo");
                int   nNo   = (GridView1.PageSize * GridView1.PageIndex) + e.Row.RowIndex + 1;
                lblNo.Text = nNo.ToString();
                DataRowView rowView            = (DataRowView)(e.Row.DataItem);
                AwNumeric   txtitem_acc_amount = (AwNumeric)e.Row.FindControl("txtitem_acc_amount");
                AwNumeric   txtitem_acc_tax    = (AwNumeric)e.Row.FindControl("txtitem_acc_tax");
                AwNumeric   txtitem_acc_total  = (AwNumeric)e.Row.FindControl("txtitem_acc_total");

                ViewState["item_acc_amount"] = decimal.Parse(ViewState["item_acc_amount"].ToString()) + decimal.Parse(txtitem_acc_amount.Value.ToString());
                ViewState["item_acc_tax"]    = decimal.Parse(ViewState["item_acc_tax"].ToString()) + decimal.Parse(txtitem_acc_tax.Value.ToString());
                ViewState["item_acc_total"]  = decimal.Parse(ViewState["item_acc_total"].ToString()) + decimal.Parse(txtitem_acc_total.Value.ToString());

                #region set Image Delete
                ImageButton imgDelete = (ImageButton)e.Row.FindControl("imgDelete");
                imgDelete.ImageUrl = ((DataSet)Application["xmlconfig"]).Tables["imgDelete"].Rows[0]["img"].ToString();
                imgDelete.Attributes.Add("title", ((DataSet)Application["xmlconfig"]).Tables["imgDelete"].Rows[0]["title"].ToString());
                imgDelete.Attributes.Add("onclick", "return confirm('คุณต้องการลบข้อมูลนี้หรือไม่')");
                #endregion
            }
            else if (e.Row.RowType.Equals(DataControlRowType.Footer))
            {
                AwNumeric txtitem_acc_amount_total = (AwNumeric)e.Row.FindControl("txtitem_acc_amount_total");
                AwNumeric txtitem_acc_tax_total    = (AwNumeric)e.Row.FindControl("txtitem_acc_tax_total");
                AwNumeric txtitem_acc_total_total  = (AwNumeric)e.Row.FindControl("txtitem_acc_total_total");
                txtitem_acc_amount_total.Value = decimal.Parse(ViewState["item_acc_amount"].ToString());
                txtitem_acc_tax_total.Value    = decimal.Parse(ViewState["item_acc_tax"].ToString());
                txtitem_acc_total_total.Value  = decimal.Parse(ViewState["item_acc_total"].ToString());
            }
        }
コード例 #6
0
        private bool saveData()
        {
            bool   blnResult  = false;
            string strMessage = string.Empty;
            //Head
            string stritem_acc_doc     = string.Empty;
            string stritem_acc_year    = string.Empty;
            string strpay_month        = string.Empty;
            string strpay_year         = string.Empty;
            string stritem_acc_comment = string.Empty;
            //Detail
            string stritem_acc_detail_id = "0";
            string stritem_acc_deka;
            string stritem_acc_group;
            string stritem_acc_amount;
            string stritem_acc_tax;
            string stritem_acc_total;
            string stritem_acc_code;
            string stritem_project_code;
            string stritem_code;
            string strproduce_code;

            string strc_user = Session["username"].ToString();

            string    strScript = string.Empty;
            bool      blnDup    = false;
            cItem_acc oItem_acc = new cItem_acc();
            DataSet   ds        = new DataSet();

            try
            {
                #region set Data
                stritem_acc_doc     = txtitem_acc_doc.Text;
                stritem_acc_year    = cboYear.SelectedValue;
                strpay_month        = cboPay_Month.SelectedValue;
                strpay_year         = cboPay_Year.SelectedValue;
                stritem_acc_comment = txtcomments.Text;
                #endregion

                if (ViewState["mode"].ToString().ToLower().Equals("add"))
                {
                    #region insert
                    string strCheckDup = string.Empty;
                    strCheckDup = " and pay_year = '" + strpay_year + "' " +
                                  " and pay_month = '" + strpay_month + "'" +
                                  " and budget_type = '" + this.BudgetType + "'" +
                                  " and c_created_by = '" + UserLoginName + "' ";
                    if (!oItem_acc.SP_ITEM_ACC_HEAD_SEL(strCheckDup, ref ds, ref strMessage))
                    {
                        lblError.Text = strMessage;
                    }
                    else
                    {
                        if (ds.Tables[0].Rows.Count > 0)
                        {
                            blnDup    = true;
                            strScript =
                                "alert(\"ไม่สามารถเพิ่มข้อมูลได้ เนื่องจาก" +
                                "\\n รอบเดือน : " + cboPay_Month.SelectedItem.Text + "   ปี : " + strpay_year +
                                "\\nซ้ำ\");\n";
                            ScriptManager.RegisterStartupScript(Page, Page.GetType(), "OpenPage", strScript, true);
                        }
                        else
                        {
                            if (!oItem_acc.SP_ITEM_ACC_HEAD_INS(stritem_acc_year, strpay_month,
                                                                strpay_year, stritem_acc_comment, strc_user, "B", ref strMessage))
                            {
                                lblError.Text = strMessage;
                            }
                            else
                            {
                                DataSet dsCHK = new DataSet();
                                strCheckDup = " and pay_year = '" + strpay_year + "' " +
                                              " and pay_month = '" + strpay_month + "' " +
                                              " and budget_type = '" + this.BudgetType + "'" +
                                              " and c_created_by = '" + UserLoginName + "' ";
                                if (!oItem_acc.SP_ITEM_ACC_HEAD_SEL(strCheckDup, ref dsCHK, ref strMessage))
                                {
                                    lblError.Text = strMessage;
                                }
                                else
                                {
                                    stritem_acc_doc           = dsCHK.Tables[0].Rows[0]["item_acc_doc"].ToString();
                                    ViewState["item_acc_doc"] = stritem_acc_doc;
                                    blnResult = true;
                                }
                            }
                        }
                    }
                    #endregion
                }
                else
                {
                    #region update
                    if (!oItem_acc.SP_ITEM_ACC_HEAD_UPD(stritem_acc_doc, stritem_acc_year, strpay_month, strpay_year,
                                                        stritem_acc_comment, strc_user, ref strMessage))
                    {
                        lblError.Text = strMessage;
                    }
                    else
                    {
                        #region insert detail
                        GridViewRow gviewRow;
                        int         i;
                        for (i = 0; i <= GridView1.Rows.Count - 1; i++)
                        {
                            gviewRow = GridView1.Rows[i];
                            Label lblitem_acc_code = (Label)gviewRow.FindControl("lblitem_acc_code");
                            //if (lblitem_acc_code.Text != "")
                            //{
                            HiddenField hdditem_acc_detail_id = (HiddenField)gviewRow.FindControl("hdditem_acc_detail_id");
                            TextBox     txtitem_acc_deka      = (TextBox)gviewRow.FindControl("txtitem_acc_deka");
                            TextBox     txtitem_acc_group     = (TextBox)gviewRow.FindControl("txtitem_acc_group");
                            TextBox     txtitem_project_code  = (TextBox)gviewRow.FindControl("txtitem_project_code");
                            AwNumeric   txtitem_acc_amount    = (AwNumeric)gviewRow.FindControl("txtitem_acc_amount");
                            AwNumeric   txtitem_acc_tax       = (AwNumeric)gviewRow.FindControl("txtitem_acc_tax");
                            AwNumeric   txtitem_acc_total     = (AwNumeric)gviewRow.FindControl("txtitem_acc_total");
                            //Label lblitem_acc_code = (Label)gviewRow.FindControl("txtitem_code");
                            Label lblitem_code             = (Label)gviewRow.FindControl("lblitem_code");
                            Label lblproduce_code          = (Label)gviewRow.FindControl("lblproduce_code");
                            Label lblperson_group_code_acc = (Label)gviewRow.FindControl("lblperson_group_code_acc");
                            Label lblpayment_back_type     = (Label)gviewRow.FindControl("lblpayment_back_type");

                            stritem_acc_detail_id = hdditem_acc_detail_id.Value.ToString();
                            stritem_acc_deka      = txtitem_acc_deka.Text.Trim();
                            stritem_acc_group     = txtitem_acc_group.Text.Trim();
                            stritem_acc_amount    = txtitem_acc_amount.Value.ToString();
                            stritem_acc_tax       = txtitem_acc_tax.Value.ToString();
                            stritem_acc_total     = txtitem_acc_total.Value.ToString();
                            stritem_acc_code      = lblitem_acc_code.Text;
                            stritem_project_code  = txtitem_project_code.Text.Trim();
                            strproduce_code       = lblproduce_code.Text;
                            stritem_code          = lblitem_code.Text;

                            if (stritem_acc_detail_id != "0")
                            {
                                if (!oItem_acc.SP_ITEM_ACC_DETAIL_UPD(stritem_acc_detail_id, txtitem_acc_doc.Text.Trim(),
                                                                      stritem_acc_deka, stritem_acc_group, stritem_acc_amount,
                                                                      stritem_acc_tax, stritem_acc_total, stritem_acc_code,
                                                                      stritem_project_code, stritem_code, strproduce_code,
                                                                      ref strMessage))
                                {
                                    lblError.Text = strMessage;
                                }
                            }
                            else
                            {
                                if (!oItem_acc.SP_ITEM_ACC_DETAIL_INS(txtitem_acc_doc.Text.Trim(), stritem_acc_deka, stritem_acc_group,
                                                                      stritem_acc_amount, stritem_acc_tax, stritem_acc_total, stritem_acc_code,
                                                                      stritem_project_code, stritem_code, strproduce_code, lblperson_group_code_acc.Text.Trim(),
                                                                      lblpayment_back_type.Text, ref strMessage))
                                {
                                    lblError.Text = strMessage;
                                }
                            }
                            //}
                        }
                        #endregion
                        blnResult = true;
                    }
                    #endregion
                }
            }
            catch (Exception ex)
            {
                lblError.Text = ex.Message.ToString();
            }
            finally
            {
                oItem_acc.Dispose();
            }
            return(blnResult);
        }
コード例 #7
0
        protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            if (e.Row.RowType.Equals(DataControlRowType.Header))
            {
                for (int iCol = 0; iCol < e.Row.Cells.Count; iCol++)
                {
                    e.Row.Cells[iCol].Attributes.Add("class", "table_h");
                    e.Row.Cells[iCol].Wrap = false;
                }

                ImageButton imgAdd = (ImageButton)e.Row.FindControl("imgAdd");
                imgAdd.ImageUrl = ((DataSet)Application["xmlconfig"]).Tables["imgGridAdd"].Rows[0]["img"].ToString();
                imgAdd.Attributes.Add("title", ((DataSet)Application["xmlconfig"]).Tables["imgGridAdd"].Rows[0]["title"].ToString());
                ViewState["TotalAmount"] = 0;
            }
            else if (e.Row.RowType.Equals(DataControlRowType.DataRow) || e.Row.RowState.Equals(DataControlRowState.Alternate))
            {
                if (!this.bIsGridDetailEmpty)
                {
                    #region Set datagrid row color
                    string strEvenColor, strOddColor, strMouseOverColor;
                    strEvenColor      = ((DataSet)Application["xmlconfig"]).Tables["colorDataGridRow"].Rows[0]["Even"].ToString();
                    strOddColor       = ((DataSet)Application["xmlconfig"]).Tables["colorDataGridRow"].Rows[0]["Odd"].ToString();
                    strMouseOverColor = ((DataSet)Application["xmlconfig"]).Tables["colorDataGridRow"].Rows[0]["MouseOver"].ToString();

                    e.Row.Style.Add("valign", "top");
                    e.Row.Style.Add("cursor", "hand");
                    e.Row.Attributes.Add("onMouseOver", "this.style.backgroundColor='" + strMouseOverColor + "'");

                    if (e.Row.RowState.Equals(DataControlRowState.Alternate))
                    {
                        e.Row.Attributes.Add("bgcolor", strOddColor);
                        e.Row.Attributes.Add("onMouseOut", "this.style.backgroundColor='" + strOddColor + "'");
                    }
                    else
                    {
                        e.Row.Attributes.Add("bgcolor", strEvenColor);
                        e.Row.Attributes.Add("onMouseOut", "this.style.backgroundColor='" + strEvenColor + "'");
                    }
                    #endregion
                    view_Budget_open_detail dv = (view_Budget_open_detail)e.Row.DataItem;
                    Label lblNo = (Label)e.Row.FindControl("lblNo");
                    int   nNo   = (GridView1.PageSize * GridView1.PageIndex) + e.Row.RowIndex + 1;
                    lblNo.Text = nNo.ToString();

                    #region set Image Delete

                    ImageButton imgDelete = (ImageButton)e.Row.FindControl("imgDelete");
                    imgDelete.ImageUrl = ((DataSet)Application["xmlconfig"]).Tables["imgDelete"].Rows[0]["img"].ToString();
                    imgDelete.Attributes.Add("title", ((DataSet)Application["xmlconfig"]).Tables["imgDelete"].Rows[0]["title"].ToString());
                    imgDelete.Attributes.Add("onclick", "return confirm(\"คุณต้องการลบข้อมูลนี้หรือไม่ ?\");");
                    //imgDelete.Visible = IsUserDelete;
                    #endregion

                    ViewState["TotalAmount"] = Helper.CDbl(ViewState["TotalAmount"]) +
                                               Helper.CDbl(dv.budget_open_detail_amount);
                }
            }
            else if (e.Row.RowType.Equals(DataControlRowType.Footer))
            {
                AwNumeric txtopen_amount = (AwNumeric)e.Row.FindControl("txtopen_amount");
                txtopen_amount.Value = Helper.CDbl(ViewState["TotalAmount"]);
            }
        }