Beispiel #1
0
    public static void addButton4Cmb(System.Web.UI.Page mypage, ASPxComboBox cmb, int Buttontype, string popupID)
    {
        string prefixCookie = mypage.GetType().ToString().Replace("ASP.", "");
        switch (Buttontype)
        {
            case 0://add cả 2 button
                AddFavButton4Cmb(cmb);
                AddNewButton4Cmb(cmb);
                cmb.ClientSideEvents.Init = "function(s,e){ GetDefaultValue4Cmb(s,'" + prefixCookie + "_" + cmb.ClientInstanceName + "'); }";
                cmb.ClientSideEvents.ButtonClick = "function(s,e){ if( e.buttonIndex == 0){setCookie('" + prefixCookie + "_" + cmb.ClientInstanceName + "',s.GetValue(),365);} else { popupWindow4Cmb('" + popupID + "');} }";
                break;
            case 1://chi add button new
                AddNewButton4Cmb(cmb);
                cmb.ClientSideEvents.ButtonClick = "function(s,e){ popupWindow4Cmb('" + popupID + "'); }";
                break;
            case 2://chỉ add button fav
                AddNewButton4Cmb(cmb);
                cmb.ClientSideEvents.Init = "function(s,e){ GetDefaultValue4Cmb(s,'" + prefixCookie + "_" + cmb.ClientInstanceName + "'); }";
                cmb.ClientSideEvents.ButtonClick = "function(s,e){ setCookie('" + prefixCookie + "_" + cmb.ClientInstanceName + "',s.GetValue(),365); }";
                break;
        }
        /*
         * <ButtonStyle BackColor="Transparent">
                        <Paddings Padding="0px" />
                        <Border BorderStyle="None" />
                    </ButtonStyle>
         */
        cmb.ClientSideEvents.GotFocus = "function(s,e){ s.SelectAll(); }";

        //cmb.ButtonStyle.BackColor = Color.Transparent;
        //cmb.ButtonStyle.Width = Unit.Pixel(15);
        //cmb.ButtonStyle.Paddings.Padding = Unit.Pixel(0);
        //cmb.ButtonStyle.Border.BorderStyle = BorderStyle.None;
        //cmb.SkinID = "cmbDefault";
    }
Beispiel #2
0
 public static void SeleccionarItemCombo(ref ASPxComboBox combo, string valor, string texto)
 {
     combo.SelectedIndex = -1;
     if ((combo.Items.FindByValue(valor) == null))
         combo.Items.Insert(0, new ListEditItem(texto, valor));
     combo.Items.FindByValue(valor).Selected = true;
 }
Beispiel #3
0
    protected void FillCombo_OLD_SYSTEM(ASPxComboBox cmb, string SYS_CODE)
    {
        try
        {
            if (string.IsNullOrEmpty(SYS_CODE)) return;
            string SQL = "";
            SQL = " SELECT  CTLT_SYS_USER_RIGHT.USER_RIGHT ROLE_ID";
            SQL += " ,SYS_CODE";
            SQL += " ,CTLT_USER_RIGHT.USER_RIGHT_DESC ROLE_NAME";
            SQL += " FROM CTLT_SYS_USER_RIGHT ";
            SQL += " LEFT JOIN CTLT_USER_RIGHT ON CTLT_USER_RIGHT.USER_RIGHT = CTLT_SYS_USER_RIGHT.USER_RIGHT";
            SQL += " WHERE SYS_CODE='" + SYS_CODE + "'";

            //string SQL = string.Format("select ROLE_ID,ROLE_NAME from ODS_SYSTEM_ROLE WHERE SYS_CODE='{0}' ORDER BY [ROLE_NAME]", SYS_CODE);
            SqlDataAdapter DA = new SqlDataAdapter(SQL, OPM_BL.DefaultConnectionString);
            DataTable DTRole = new DataTable();
            DA.Fill(DTRole);
            cmb.DataSource = DTRole;
            cmb.ValueField = "ROLE_ID";
            cmb.TextField = "ROLE_NAME";
            cmb.DataBindItems();

            //AccessDataSource2.FilterExpression = "  SYS_CODE='" + SYS_CODE + "'";
            //DataView dv = (DataView)AccessDataSource2.Select(DataSourceSelectArguments.Empty);
            //DataTable DT = dv.ToTable();
        }
        catch (Exception ex)
        {

        }
    }
Beispiel #4
0
    protected void FillCombo(ASPxComboBox cmb, string SYS_CODE)
    {
        try
        {
            if (string.IsNullOrEmpty(SYS_CODE)) return;
            //AccessDataSource2.SelectParameters.Clear();
            ////string SQL = AccessDataSource2.SelectCommand;
            //AccessDataSource2.SelectCommand = " select SYS_CODE ,ROLE_ID,ROLE_NAME from ODS_SYSTEM_ROLE  ";
            //AccessDataSource2.SelectCommand = SQL;

            string SQL = string.Format("select ROLE_ID,ROLE_NAME from ODS_SYSTEM_ROLE WHERE SYS_CODE='{0}' ORDER BY [ROLE_NAME]", SYS_CODE);
            SqlDataAdapter DA = new SqlDataAdapter(SQL, OPM_BL.DefaultConnectionString);
            DataTable DTRole = new DataTable();
            DA.Fill(DTRole);
            cmb.DataSource = DTRole;
            cmb.ValueField = "ROLE_ID";
            cmb.TextField = "ROLE_NAME";
            cmb.DataBindItems();

            //AccessDataSource2.FilterExpression = "  SYS_CODE='" + SYS_CODE + "'";
            //DataView dv = (DataView)AccessDataSource2.Select(DataSourceSelectArguments.Empty);
            //DataTable DT = dv.ToTable();
        }
        catch (Exception ex)
        {

        }
    }
Beispiel #5
0
 public static void AddFavButton4Cmb(ASPxComboBox cmb)
 {
     var btnFav = new EditButton { Position = ButtonsPosition.Left };
     btnFav.Image.Url = "~/img/btnico/star.png";
     btnFav.Image.Width = Unit.Pixel(16);
     btnFav.ToolTip = "Nhấn vào đây để chọn mục này là mặc định cho lần sau.";
     cmb.Buttons.Add(btnFav);
 }
Beispiel #6
0
 protected void FillSectionCombo(ASPxComboBox cmb, string SiteID)
 {
     if (SiteID == "0") return;
     cmb.DataSourceID = "ObjectDataSourceSection";
     ObjectDataSourceSection.SelectParameters[0].DefaultValue = SiteID;
     cmb.DataBindItems();
     cmb.Items.Insert(0, new ListEditItem("", null)); // Null Item
 }
Beispiel #7
0
    /*
     <dx:EditButton Position="Left" ToolTip="<%$ Resources:Control, DefaultButton.Tooltip %>">
                                <Image Height="16px" Url="~/img/btnico/star.png" Width="16px">
                                </Image>
                            </dx:EditButton>
                            <dx:EditButton ToolTip="<%$ Resources:Control, AddButton.Tooltip %>">
                                <Image Url="~/img/common/Add.png" Width="16px">
                                </Image>
                            </dx:EditButton>
     */
    public static void AddNewButton4Cmb(ASPxComboBox cmb)
    {
        var btnNew = new EditButton { Position = ButtonsPosition.Right };
        btnNew.Image.Url = "~/img/common/Add.png";
        btnNew.Image.Width = Unit.Pixel(16);
        btnNew.ToolTip = "Nhấn vào đây để tạo mới thêm danh mục này";

        cmb.Buttons.Add(btnNew);
    }
Beispiel #8
0
 /// <summary>
 /// Tao nut add/fav/refresh
 /// </summary>
 /// <param name="cmb">Truyen vao control combobox</param>
 /// <param name="type">Truyen vao loai nut. 0 : Fav; 1:Fav+Add;2:Fav+Add+Refresh;3:Only Refresh;4:Only Add;5: Fav+Refresh</param>
 public void buildcmbButton(ASPxComboBox cmb, int type, string popupCode = "")
 {
     int modulePage = -1;
     try
     {
         Int32.TryParse(CU.getCurrentModuleID().ToString(), out modulePage);
     }
     catch (System.NullReferenceException) { }
     int width = 500;
     int height = 500;
     string title = "Error load Page!!!";
     string param = "";
     DataTable dtPopupWindow = new DataTable();
     dtPopupWindow = SY_GetModuleID_for_PopUpcontrol(popupCode);
     if (dtPopupWindow.Rows.Count > 0)
     {
         SiAuto.Main.LogDataTable(dtPopupWindow);
         moduleID = int.Parse(dtPopupWindow.Rows[0]["moduleID"].ToString());
         width = int.Parse(dtPopupWindow.Rows[0]["width"].ToString());
         height = int.Parse(dtPopupWindow.Rows[0]["height"].ToString());
         title = dtPopupWindow.Rows[0]["title"].ToString();
         param = dtPopupWindow.Rows[0]["paramArray"].ToString();
     }
     else
         return;
     SiAuto.Main.LogInt("ModulePage=", modulePage);
     SiAuto.Main.LogInt("ModuleID=", moduleID);
     switch (type)
     {
         case 0:
             buildFavBtn(cmb, modulePage);
             break;
         case 1:
             if (checkPermissionBtn(moduleID))
                 buildFavAddBtn(cmb, popupCode, modulePage, moduleID, width, height, title, param);
             else buildFavBtn(cmb, modulePage);
             break;
         case 2:
             if (checkPermissionBtn(moduleID))
                 buildAllBtn(cmb, popupCode, modulePage, moduleID, width, height, title, param);
             else buildFavRefresh(cmb, modulePage);
             break;
         case 3:
             buildRefreshBtn(cmb);
             break;
         case 4:
             if (checkPermissionBtn(moduleID))
                 buildAddBtn(cmb, popupCode, moduleID, width, height, title, param);
             break;
         case 5:
             buildFavRefresh(cmb, modulePage);
             break;
         default:
             break;
     }
 }
 static void InitDurationCombo(ASPxComboBox cbSnooze) {
     cbSnooze.Items.Clear();
     TimeSpan[] snoozeTimeSpans = GetTimeSpans();
     int length = snoozeTimeSpans.Length;
     for (int i = 0; i < length; i++) {
         TimeSpan span = snoozeTimeSpans[i];
         cbSnooze.Items.Add(new ListEditItem(ConvertTimeSpanToString(span), span));
     }
     cbSnooze.SelectedIndex = 4;
 }
Beispiel #10
0
        public List<WebControl> RenderControl(XmlNode xmlControl)
        {
            base.Initialize(xmlControl);

            ASPxComboBox aspxListBox = new ASPxComboBox
            {
                ID = _PropertyMapper.GetID(),
                ClientInstanceName = _PropertyMapper.GetID()
            };

            if (string.IsNullOrEmpty(_PropertyMapper.GetDefault()))
                aspxListBox.SelectedIndex = 0;

            aspxListBox.Callback += new DevExpress.Web.ASPxClasses.CallbackEventHandlerBase(aspxListBox_Callback);
            XmlNode valuesNode = _PropertyMapper.GetValuesNode();

            // Carga los datos de la lista
            foreach (XmlNode xmlValueNode in valuesNode.ChildNodes)
            {
                ListEditItem listEditItem = new ListEditItem();

                    listEditItem.Value = xmlValueNode.GetAttribute("CCLAVE");
                    listEditItem.Text = xmlValueNode.GetAttribute("CTEXTO");
                    listEditItem.Selected = (_PropertyMapper.GetDefault() == xmlValueNode.GetAttribute("CCLAVE")) ? true : false;

                    aspxListBox.Items.Add(listEditItem);

            }

            try
            {
                if (xmlControl.GetAttribute("CCONTROLASOC") != null)
                {
                    aspxListBox.ClientSideEvents.ValueChanged = "function(s, e) {" + xmlControl.GetAttribute("CCONTROLASOC") + ".PerformCallback(" + _PropertyMapper.GetID() + ".GetValue());}";
                    aspxListBox.ClientSideEvents.Init = "function(s, e) {" + xmlControl.GetAttribute("CCONTROLASOC") + ".PerformCallback(" + _PropertyMapper.GetID() + ".GetValue());}";
                }
            }
            catch (Exception)
            {
            }

            _Controls.Add(aspxListBox);

            return _Controls;
        }
Beispiel #11
0
        void FillEditor(ASPxComboBox editor) {
            if (editor == null) return;
            editor.Items.Clear();
            editor.ValueType = GetComboBoxValueType();

            IEnumerable dataSource = GetDataSource();

            if (_propertyType.IsGenericType && _propertyType.GetGenericTypeDefinition() == typeof(Nullable<>)) {
                editor.Items.Add(CaptionHelper.NullValueText, null);
            }

            if (dataSource != null)
                foreach (object value in dataSource) {
                    if (value is ListEditItem)
                        editor.Items.Add(value as ListEditItem);
                    else
                        editor.Items.Add(CreateEditItem(value));
                }
        }
Beispiel #12
0
        /// <summary>
        /// Binds the DataTable to ComboBox list with given value and text fields
        /// </summary>
        /// <param name="cmbBox">Name of the ComboBox list to process</param>
        /// <param name="dt">DataTable to Bind</param>
        /// <param name="strValue">Value field name as string</param>
        /// <param name="strText">Text fiels name as string</param>
        public static void BindDropDown(ASPxComboBox cmbBox, DataTable dt, string strValue, string strText)
        {
            // clsDataFunctionsBAL objFunctions = null;

            try
            {
                if (DataTableHasRows(dt))
                {
                    cmbBox.DataSource = dt;
                    cmbBox.ValueField = strValue;
                    cmbBox.TextField = strText;
                    cmbBox.DataBindItems();
                }
            }
            catch (Exception ex)
            {
                //objFunctions = new clsDataFunctionsBAL();
                //objFunctions.SaveErrorLog(ex.Message, m_strModule, MethodBase.GetCurrentMethod().Name);
            }
            finally
            {
               // objFunctions = null;
            }
        }
Beispiel #13
0
    // แสดงชื่อตำแหน่งของลูกจ้างโครงการ ไกท์ไลน์
    public static void SetDDLPositionNameOtherType(ASPxComboBox ddl)
    {
        try
        {
            string sql = "";
             sql += " SELECT  ROW_NUMBER() OVER(ORDER BY LINE_INORG ASC) AS Row,LINE_INORG FROM ( ";
             sql += "   SELECT DISTINCT  LINE_INORG  FROM PSST_POSITION  WHERE PER_TYPE in ('23','Z0') AND POS_Status=1 AND LINE_INORG IS NOT NULL  ";
             sql += " )AS TB ORDER BY LINE_INORG ";

            SqlDataAdapter da = new SqlDataAdapter(sql, StaticDefaultConnectionString);
            DataTable dt = new DataTable();
            da.Fill(dt);

            if (dt.Rows.Count > 0)
            {
                ddl.Columns.Clear();
                ddl.Columns.Add("LINE_INORG", "ตำแหน่ง");

                ddl.ValueField = "Row";
                ddl.TextField = "LINE_INORG";

                ddl.DataSource = dt;
                ddl.DataBind();
            }
        }
        catch (Exception ex)
        {

        }
    }
Beispiel #14
0
    public static void SetDDLPERSONBYPERTYPE(ASPxComboBox ddl, string per_type, bool IsAll = false)
    {
        try
        {
            string sql = " select ID,PREFIX_NAME + NAME + ' ' + SURNAME PER_FULLNAME   ";
            sql += " from vw_CMN_PERSON  ";
            sql += " where name is not null and  per_type='" + per_type + "'  ";
            sql += " AND RETIRE_DATE>GetDate() ";
            sql += " AND ID IN ( SELECT ID  FROM PSST_POSITION  WHERE PER_TYPE='" + per_type  + "' AND POS_STATUS=1 AND LENGTH_CODE LIKE 'K%') ";
            sql += " order by name,surname ";

            //string sql = "select ID,PREFIX_NAME + NAME + ' ' + SURNAME PER_FULLNAME  from vw_CMN_PERSON ";
            //sql += " where name is not null and  per_type='" + per_type + "' order by name,surname";

            DataTable dt = new DataTable();
            dt = OPM_BL.GetDatatable(sql, null);

            if (dt.Rows.Count > 0)
            {
                //ddl.Columns.Clear();
                //ddl.Columns.Add("ID", "เลขที่");
                //ddl.Columns.Add("PER_FULLNAME", "ชื่อ");

                if (IsAll == true)
                {
                    DataRow dr = dt.NewRow();
                    dr["ID"] = "0";
                    dr["PER_FULLNAME"] = "ทั้งหมด";
                    dt.Rows.InsertAt(dr, 0);
                }

                ddl.ValueField = "ID";
                ddl.TextField = "PER_FULLNAME";

                ddl.DataSource = dt;
                ddl.DataBind();

                //ddl.SelectedIndex = 0;
            }
        }
        catch (Exception ex)
        {

        }
    }
Beispiel #15
0
    public static void SetDDLPerTypeISMAIN1(ASPxComboBox ddl, bool isAll = false)
    {
        try
        {
            string sql = "select PER_TYPE,PER_TYPE_NAME from SMM_PER_TYPE Where IS_MAIN =1 ORDER BY PER_TYPE_NAME";

            DataTable dt = GetDatatable(sql, null);
            if (dt.Rows.Count > 0)
            {
                if (isAll == true)
                {
                    DataRow dr = dt.NewRow();
                    dr["PER_TYPE"] = "0";
                    dr["PER_TYPE_NAME"] = "ทั้งหมด";
                    dt.Rows.InsertAt(dr, 0);
                }

                ddl.ValueField = "PER_TYPE";
                ddl.TextField = "PER_TYPE_NAME";

                ddl.DataSource = dt;
                ddl.DataBind();
            }
        }
        catch (Exception ex)
        {

        }
    }
Beispiel #16
0
    public static void SetDDLJDEVALSCORE(ASPxComboBox ddl)
    {
        try
        {

            DataTable dt =new DataTable();
            dt.Columns.Add("Score_ID");
            dt.Columns.Add("Score_Name");

            DataRow dr ;
            dr=dt.NewRow();
            dr["Score_ID"]="0";
            dr["Score_Name"]="เลือกระดับ";
            dt.Rows.Add(dr);

            dr=dt.NewRow();
            dr["Score_ID"]="1";
            dr["Score_Name"]="ระดับ 1";
            dt.Rows.Add(dr);

            dr=dt.NewRow();
            dr["Score_ID"]="2";
            dr["Score_Name"]="ระดับ 2";
            dt.Rows.Add(dr);

            dr=dt.NewRow();
            dr["Score_ID"]="3";
            dr["Score_Name"]="ระดับ 3";
            dt.Rows.Add(dr);

            dr=dt.NewRow();
            dr["Score_ID"]="4";
            dr["Score_Name"]="ระดับ 4";
            dt.Rows.Add(dr);

            dr=dt.NewRow();
            dr["Score_ID"]="5";
            dr["Score_Name"]="ระดับ 5";
            dt.Rows.Add(dr);

            ddl.ValueField = "Score_ID";
            ddl.TextField = "Score_Name";

            ddl.DataSource = dt;
            ddl.DataBind();

        }
        catch (Exception ex)
        {

        }
    }
Beispiel #17
0
    public static void SetDDLORG(ASPxComboBox ddl)
    {
        try
        {
            string sql = "SELECT '' ORG_SERIAL,'เลือกหน่วยงาน' ORG_NAME,'' ORG_ABBR UNION ALL SELECT CONVERT(varchar,ORG_SERIAL) ORG_SERIAL,ORG_NAME,ORG_ABBR FROM vw_SMM_ORG";
            SqlDataAdapter da = new SqlDataAdapter(sql, StaticDefaultConnectionString);
            DataTable dt = new DataTable();
            da.Fill(dt);

            if (dt.Rows.Count > 0)
            {
                ddl.Columns.Clear();
                ddl.Columns.Add("ORG_NAME", "ชื่อหน่วยงาน");
                ddl.Columns.Add("ORG_ABBR", "ชื่อย่อ");

                ddl.ValueField = "ORG_SERIAL";
                ddl.TextField = "ORG_NAME";

                ddl.DataSource = dt;
                ddl.DataBind();
            }
        }
        catch (Exception ex)
        {

        }
    }
Beispiel #18
0
    private void job_save()
    {
        try
        {
            ASPxPageControl            pageControl = this.grid_job.FindEditFormTemplateControl("pageControl") as ASPxPageControl;
            ASPxTextBox                txt_JobNo   = pageControl.FindControl("txt_JobNo") as ASPxTextBox;
            string                     jobNo       = SafeValue.SafeString(txt_JobNo.Text, "");
            Wilson.ORMapper.OPathQuery query       = new Wilson.ORMapper.OPathQuery(typeof(C2.CtmJob), "JobNo='" + jobNo + "'");
            C2.CtmJob                  ctmJob      = C2.Manager.ORManager.GetObject(query) as C2.CtmJob;

            ASPxDateEdit jobDate = pageControl.FindControl("txt_JobDate") as ASPxDateEdit;
            bool         isNew   = false;
            if (ctmJob == null)
            {
                isNew        = true;
                ctmJob       = new C2.CtmJob();
                ctmJob.JobNo = C2Setup.GetNextNo("", "CTM_Job", jobDate.Date);
            }
            ASPxDateEdit jobEta = pageControl.FindControl("date_Eta") as ASPxDateEdit;
            ASPxDateEdit jobEtd = pageControl.FindControl("date_Etd") as ASPxDateEdit;
            //ASPxButtonEdit partyId = pageControl.FindControl("btn_PartyId") as ASPxButtonEdit;
            ASPxTextBox ves = pageControl.FindControl("txt_Ves") as ASPxTextBox;
            ASPxTextBox voy = pageControl.FindControl("txt_Voy") as ASPxTextBox;
            //ASPxButtonEdit carrier = pageControl.FindControl("btn_CarrierId") as ASPxButtonEdit;
            //ASPxTextBox CarrierBlNo = pageControl.FindControl("txt_CarrierBlNo") as ASPxTextBox;
            //ASPxTextBox CarrierBkgNo = pageControl.FindControl("txt_CarrierBkgNo") as ASPxTextBox;
            ASPxComboBox Terminal           = pageControl.FindControl("cbb_Terminal") as ASPxComboBox;
            ASPxMemo     PickupFrom         = pageControl.FindControl("txt_PickupFrom") as ASPxMemo;
            ASPxMemo     DeliveryTo         = pageControl.FindControl("txt_DeliveryTo") as ASPxMemo;
            ASPxMemo     Remark             = pageControl.FindControl("txt_Remark") as ASPxMemo;
            ASPxMemo     SpecialInstruction = pageControl.FindControl("txt_SpecialInstruction") as ASPxMemo;
            ASPxTextBox  txt_Pol            = pageControl.FindControl("txt_Pol") as ASPxTextBox;
            ASPxTextBox  txt_Pod            = pageControl.FindControl("txt_Pod") as ASPxTextBox;
            ASPxTextBox  txt_EtaTime        = pageControl.FindControl("txt_EtaTime") as ASPxTextBox;
            ASPxTextBox  txt_EtdTime        = pageControl.FindControl("txt_EtdTime") as ASPxTextBox;
            ASPxComboBox cbb_JobType        = pageControl.FindControl("cbb_JobType") as ASPxComboBox;
            //ASPxButtonEdit btn_ClientId = pageControl.FindControl("btn_ClientId") as ASPxButtonEdit;
            ASPxTextBox txt_ClientRefNo = pageControl.FindControl("txt_ClientRefNo") as ASPxTextBox;
            //ASPxButtonEdit btn_HaulierId = pageControl.FindControl("btn_HaulierId") as ASPxButtonEdit;
            ctmJob.JobDate = SafeValue.SafeDate(jobDate.Date, new DateTime(1753, 1, 1));
            ctmJob.EtaDate = SafeValue.SafeDate(jobEta.Date, new DateTime(1753, 1, 1));
            ctmJob.EtdDate = SafeValue.SafeDate(jobEtd.Date, new DateTime(1753, 1, 1));
            //ctmJob.PartyId = partyId.Text;
            ctmJob.Vessel             = ves.Text;
            ctmJob.Voyage             = voy.Text;
            ctmJob.CarrierId          = "";
            ctmJob.CarrierBlNo        = "";
            ctmJob.CarrierBkgNo       = "";
            ctmJob.Terminalcode       = SafeValue.SafeString(Terminal.Value);
            ctmJob.PickupFrom         = PickupFrom.Text;
            ctmJob.DeliveryTo         = DeliveryTo.Text;
            ctmJob.Remark             = Remark.Text;
            ctmJob.SpecialInstruction = SpecialInstruction.Text;
            ctmJob.Pol         = txt_Pol.Text;
            ctmJob.Pod         = txt_Pod.Text;
            ctmJob.EtaTime     = txt_EtaTime.Text;
            ctmJob.EtdTime     = txt_EtdTime.Text;
            ctmJob.JobType     = cbb_JobType.Text;
            ctmJob.ClientId    = "";
            ctmJob.ClientRefNo = txt_ClientRefNo.Text;
            ctmJob.HaulierId   = "";

            string userId = HttpContext.Current.User.Identity.Name;
            if (isNew)
            {
                ctmJob.StatusCode = "USE";

                ctmJob.CreateBy       = userId;
                ctmJob.CreateDateTime = DateTime.Now;
                ctmJob.UpdateBy       = userId;
                ctmJob.UpdateDateTime = DateTime.Now;
                C2.Manager.ORManager.StartTracking(ctmJob, Wilson.ORMapper.InitialState.Inserted);
                C2.Manager.ORManager.PersistChanges(ctmJob);
            }
            else
            {
                ctmJob.UpdateBy       = userId;
                ctmJob.UpdateDateTime = DateTime.Now;
                C2.Manager.ORManager.StartTracking(ctmJob, Wilson.ORMapper.InitialState.Updated);
                C2.Manager.ORManager.PersistChanges(ctmJob);
            }

            if (isNew)
            {
                txt_JobNo.Text = ctmJob.JobNo;
                //txt_search_JobNo.Text = txt_JobNo.Text;
                C2Setup.SetNextNo("", "CTM_Job", ctmJob.JobNo, jobDate.Date);
            }
            Session["CTM_Job"]          = "JobNo='" + ctmJob.JobNo + "'";
            this.dsJob.FilterExpression = Session["CTM_Job"].ToString();
            if (this.grid_job.GetRow(0) != null)
            {
                this.grid_job.StartEdit(0);
            }
        }
        catch { }
    }
    private void SaveAndUpdate()
    {
        ASPxTextBox    cerId           = this.ASPxGridView1.FindEditFormTemplateControl("txt_Id") as ASPxTextBox;
        ASPxComboBox   cmb_PartyTo     = this.ASPxGridView1.FindEditFormTemplateControl("cmb_PartyTo") as ASPxComboBox;
        ASPxDateEdit   txt_CerDt       = this.ASPxGridView1.FindEditFormTemplateControl("txt_CerDt") as ASPxDateEdit;
        ASPxTextBox    txt_GstPermitNo = this.ASPxGridView1.FindEditFormTemplateControl("txt_GstPermitNo") as ASPxTextBox;
        ASPxSpinEdit   spin_GstPaidAmt = this.ASPxGridView1.FindEditFormTemplateControl("spin_GstPaidAmt") as ASPxSpinEdit;
        ASPxTextBox    serialNo        = this.ASPxGridView1.FindEditFormTemplateControl("txt_SerialNo") as ASPxTextBox;
        ASPxTextBox    mastRefNCtr     = this.ASPxGridView1.FindEditFormTemplateControl("txt_MastRefNo") as ASPxTextBox;
        ASPxTextBox    jobRefNCtr      = this.ASPxGridView1.FindEditFormTemplateControl("txt_JobRefNo") as ASPxTextBox;
        ASPxTextBox    jobType         = this.ASPxGridView1.FindEditFormTemplateControl("txt_MastType") as ASPxTextBox;
        ASPxButtonEdit btn_RefCurrency = this.ASPxGridView1.FindEditFormTemplateControl("btn_RefCurrency") as ASPxButtonEdit;
        ASPxSpinEdit   txt_RefExRate   = this.ASPxGridView1.FindEditFormTemplateControl("txt_RefExRate") as ASPxSpinEdit;

        C2.SeaCertificate cer = Manager.ORManager.GetObject(typeof(SeaCertificate), SafeValue.SafeInt(cerId.Text, 0)) as SeaCertificate;

        if (cer == null)// first insert invoice
        {
            cer              = new SeaCertificate();
            cer.GstPermitNo  = txt_GstPermitNo.Text;
            cer.GstPaidAmt   = SafeValue.SafeDecimal(spin_GstPaidAmt.Value);
            cer.HandingAgent = SafeValue.SafeString(cmb_PartyTo.Value);
            cer.CerDate      = txt_CerDt.Date;
            cer.RefNo        = mastRefNCtr.Text;
            cer.JobNo        = jobRefNCtr.Text;
            cer.RefType      = jobType.Text;
            cer.SerialNo     = serialNo.Text;
            cer.Currency     = btn_RefCurrency.Text;
            cer.ExRate       = SafeValue.SafeDecimal(txt_RefExRate.Value);
            try
            {
                C2.Manager.ORManager.StartTracking(cer, Wilson.ORMapper.InitialState.Inserted);
                C2.Manager.ORManager.PersistChanges(cer);
            }
            catch
            {
            }
        }
        else
        {
            cer.GstPermitNo  = txt_GstPermitNo.Text;
            cer.GstPaidAmt   = SafeValue.SafeDecimal(spin_GstPaidAmt.Value);
            cer.HandingAgent = SafeValue.SafeString(cmb_PartyTo.Value);
            cer.CerDate      = txt_CerDt.Date;
            cer.RefNo        = mastRefNCtr.Text;
            cer.JobNo        = jobRefNCtr.Text;
            cer.RefType      = jobType.Text;
            cer.SerialNo     = serialNo.Text;
            cer.Currency     = btn_RefCurrency.Text;
            cer.ExRate       = SafeValue.SafeDecimal(txt_RefExRate.Value);
            try
            {
                Manager.ORManager.StartTracking(cer, InitialState.Updated);
                Manager.ORManager.PersistChanges(cer);
            }
            catch
            {
            }
        }
        Session["ExportCertificate"]        = "Id=" + cer.Id;
        this.dsCertificate.FilterExpression = Session["ExportCertificate"].ToString();
        if (this.ASPxGridView1.GetRow(0) != null)
        {
            this.ASPxGridView1.StartEdit(0);
        }
    }
Beispiel #20
0
        protected void ASPxCallbackPanel1_Callback(object sender, DevExpress.Web.ASPxClasses.CallbackEventArgsBase e)
        {
            ASPxTextBox     txtTrainingEmpId     = ASPxCallbackPanel1.FindControl("RoundPanelDaoTao2").FindControl("txtTrainingEmpId") as ASPxTextBox;
            ASPxTextBox     txtTrainingId        = ASPxCallbackPanel1.FindControl("RoundPanelDaoTao2").FindControl("txtTrainingId") as ASPxTextBox;
            ASPxTextBox     txtSkill             = ASPxCallbackPanel1.FindControl("RoundPanelDaoTao2").FindControl("txtSkill") as ASPxTextBox;
            ASPxTextBox     txtDecision          = ASPxCallbackPanel1.FindControl("RoundPanelDaoTao2").FindControl("txtTrainingDecision") as ASPxTextBox;
            ASPxTextBox     txtCoSoDaoTao        = ASPxCallbackPanel1.FindControl("RoundPanelDaoTao2").FindControl("txtCoSoDaoTao") as ASPxTextBox;
            ASPxTextBox     txtTrainingDecision  = ASPxCallbackPanel1.FindControl("RoundPanelDaoTao2").FindControl("txtTrainingDecision") as ASPxTextBox;
            ASPxDateEdit    calDateEnd           = ASPxCallbackPanel1.FindControl("RoundPanelDaoTao2").FindControl("calDateEnd") as ASPxDateEdit;
            ASPxDateEdit    calStartDateTraining = ASPxCallbackPanel1.FindControl("RoundPanelDaoTao2").FindControl("calStartDateTraining") as ASPxDateEdit;
            ASPxListBox     lstBoxChon           = ASPxCallbackPanel1.FindControl("RoundPanelDaoTao1").FindControl("lbChoosen") as ASPxListBox;
            ASPxTextBox     txtFee           = ASPxCallbackPanel1.FindControl("RoundPanelDaoTao2").FindControl("txtFee") as ASPxTextBox;
            ASPxComboBox    cboQualification = ASPxCallbackPanel1.FindControl("RoundPanelDaoTao2").FindControl("cboQualification") as ASPxComboBox;
            ASPxComboBox    cboTrainingForm  = ASPxCallbackPanel1.FindControl("RoundPanelDaoTao2").FindControl("cboTrainingForm") as ASPxComboBox;
            ASPxComboBox    cmbDonViToChuc   = ASPxCallbackPanel1.FindControl("RoundPanelDaoTao2").FindControl("cmbDonViToChuc") as ASPxComboBox;
            ASPxComboBox    cmbDiaDiemDaoTao = ASPxCallbackPanel1.FindControl("RoundPanelDaoTao2").FindControl("cmbDiaDiemDaoTao") as ASPxComboBox;
            ASPxDateEdit    tuNgay           = ASPxCallbackPanel1.FindControl("RoundPanelDaoTao2").FindControl("calStartDateTraining") as ASPxDateEdit;
            ASPxDateEdit    denNgay          = ASPxCallbackPanel1.FindControl("RoundPanelDaoTao2").FindControl("calDateEnd") as ASPxDateEdit;
            ASPxComboBox    cboResult        = ASPxCallbackPanel1.FindControl("RoundPanelDaoTao2").FindControl("cboResult") as ASPxComboBox;
            ASPxHiddenField HiddentfileKem   = ASPxCallbackPanel1.FindControl("RoundPanelDaoTao2").FindControl("HiddentfileKem") as ASPxHiddenField;
            ASPxCheckBox    checkCamKet      = ASPxCallbackPanel1.FindControl("RoundPanelDaoTao2").FindControl("checkCamKet") as ASPxCheckBox;


            if (e.Parameter.ToString().Equals("1"))
            {
                txtCoSoDaoTao.Text = "";
                txtDecision.Text   = "";
                txtFee.Text        = "";
                txtSkill.Text      = "";
                LoadcboQualification();
                LoadcboTrainingForm();
                LoadcmbDiaDiemDaoTao();
                lbChoosen.Items.Clear();
                lstBoxChon.EnableViewState = false;
                Session["Add"]             = 1;
                lbChoosen.EnableViewState  = false;
            }
            else if (e.Parameter.ToString().Equals(""))
            {
                txtDecision.ReadOnly = false;
                List <Training.TrainingInfo> emps = objTraining.GetTrainingByDecision(txtDecision.Text.ToString());

                if (emps.Count > 0)
                {
                    foreach (Training.TrainingInfo item in emps)
                    {
                        this.training = objTraining.GetTraining(Int32.Parse(item.id.ToString()));
                        if (this.training != null)
                        {
                            this.objTraining.DeleteTraining(training);
                        }
                    }
                }

                if (Session["Add"] != null)
                {
                    if (Session["Decision"] != null)
                    {
                        List <Training.TrainingInfo> list = objTraining.GetTrainingByDecision(Session["Decision"].ToString());
                        foreach (Training.TrainingInfo obj in list)
                        {
                            ListEditItem item = lbChoosen.Items.FindByValue(obj.employeeid.ToString());
                            if (item != null)
                            {
                                lbChoosen.Items.Remove(item);
                            }
                        }
                    }
                    foreach (ListEditItem item in lbChoosen.Items)
                    {
                        this.training.id              = -1;
                        this.training.donvitochucId   = Convert.ToInt32(cmbDonViToChuc.SelectedItem.Value.ToString());
                        this.training.diadiemtochucId = Convert.ToInt32(cmbDiaDiemDaoTao.SelectedItem.Value.ToString());
                        this.training.decision        = txtDecision.Text;
                        this.training.schoolname      = txtCoSoDaoTao.Text.Trim();
                        this.training.skill           = txtSkill.Text;
                        this.training.fee             = txtFee.Text;
                        this.training.fromdate        = Convert.ToDateTime(calStartDateTraining.Value);
                        this.training.todate          = Convert.ToDateTime(calDateEnd.Value);
                        this.training.editor          = this.UserId;
                        this.training.result          = cboResult.SelectedItem.Text;
                        this.training.modifieddate    = DateTime.Now;
                        this.training.ip              = HttpContext.Current.Request.UserHostAddress;
                        this.training.employeeid      = Int32.Parse(item.Value.ToString());
                        this.training.qualificationid = Int32.Parse(cboQualification.SelectedItem.Value.ToString());
                        this.training.trainingformid  = Int32.Parse(cboTrainingForm.SelectedItem.Value.ToString());
                        this.training.camket          = checkCamKet.Checked == true ? checkCamKet.Checked : false;
                        if (Session["img"] != null)
                        {
                            this.training.fileKem = Session["img"].ToString();
                        }
                        Session.Remove("img");
                        objTraining.AddTraining(this.training);
                    }
                }
                else
                {
                    foreach (ListEditItem item in lbChoosen.Items)
                    {
                        this.training.id              = -1;
                        this.training.donvitochucId   = Convert.ToInt32(cmbDonViToChuc.SelectedItem.Value.ToString());
                        this.training.diadiemtochucId = Convert.ToInt32(cmbDiaDiemDaoTao.SelectedItem.Value.ToString());
                        this.training.decision        = txtDecision.Text;
                        this.training.schoolname      = txtCoSoDaoTao.Text.Trim();
                        this.training.skill           = txtSkill.Text;
                        this.training.fee             = txtFee.Text;
                        this.training.fromdate        = Convert.ToDateTime(calStartDateTraining.Value);
                        this.training.todate          = Convert.ToDateTime(calDateEnd.Value);
                        this.training.result          = cboResult.SelectedItem.Text;
                        this.training.editor          = this.UserId;
                        this.training.modifieddate    = DateTime.Now;
                        this.training.ip              = HttpContext.Current.Request.UserHostAddress;
                        this.training.employeeid      = Int32.Parse(item.Value.ToString());
                        this.training.qualificationid = Int32.Parse(cboQualification.SelectedItem.Value.ToString());
                        this.training.trainingformid  = Int32.Parse(cboTrainingForm.SelectedItem.Value.ToString());
                        this.training.camket          = checkCamKet.Checked == true ? checkCamKet.Checked : false;
                        if (Session["img"] != null)
                        {
                            this.training.fileKem = Session["img"].ToString();
                        }
                        Session.Remove("img");
                        objTraining.AddTraining(this.training);
                    }
                }
                Session["Decision"] = txtDecision.Text.Trim();
                Session.Remove("Add");
                ASPxWebControl.RedirectOnCallback(DotNetNuke.Common.Globals.ApplicationPath + "/Default.aspx?tabid=232");
            }
            else if (e.Parameter.ToString().Equals("2"))
            {
                Session.Remove("Add");
                List <Training.TrainingInfo> list = objTraining.GetTrainingByDecision(cmbQuyetDinh.SelectedItem.Value.ToString());
                foreach (Training.TrainingInfo obj in list)
                {
                    this.training = obj;
                }
                if (this.training != null)
                {
                    if (training.schoolname != null)
                    {
                        txtCoSoDaoTao.Text = training.schoolname.ToString();
                    }
                    if (training.decision != null)
                    {
                        txtDecision.Text = training.decision.ToString();
                    }
                    if (training.fee != null)
                    {
                        txtFee.Text = training.fee.ToString();
                    }
                    if (training.skill != null)
                    {
                        txtSkill.Text = training.skill.ToString();
                    }

                    //txtDecision.ReadOnly = true;
                    ListEditItem item1 = cboQualification.Items.FindByValue(training.qualificationid.ToString());
                    if (item1 != null)
                    {
                        item1.Selected = true;
                    }
                    ListEditItem item7 = cboResult.Items.FindByText(training.result.ToString());
                    if (item7 != null)
                    {
                        item7.Selected = true;
                    }
                    ListEditItem item2 = cboTrainingForm.Items.FindByValue(training.trainingformid.ToString());
                    if (item2 != null)
                    {
                        item2.Selected = true;
                    }
                    ListEditItem item3 = cmbDonViToChuc.Items.FindByValue(training.donvitochucId.ToString());
                    if (item3 != null)
                    {
                        item3.Selected = true;
                    }
                    ListEditItem item4 = cmbDiaDiemDaoTao.Items.FindByValue(training.diadiemtochucId.ToString());
                    if (item4 != null)
                    {
                        item4.Selected = true;
                    }
                    tuNgay.Date  = training.fromdate;
                    denNgay.Date = training.todate;
                }
            }
        }
Beispiel #21
0
 public static ASPxComboBox MontaComboEmpresa(ASPxComboBox pCombo)
 {
     return(SreDblib.MontaCombo(pCombo, "empresa", "apelido", "apelido", false, ""));
 }
Beispiel #22
0
    private void SaveBill()
    {
        #region save
        ASPxTextBox  oidCtr         = this.ASPxGridView1.FindEditFormTemplateControl("txt_Oid") as ASPxTextBox;
        ASPxComboBox partyTo        = this.ASPxGridView1.FindEditFormTemplateControl("cmb_PartyTo") as ASPxComboBox;
        ASPxTextBox  otherPartyName = this.ASPxGridView1.FindEditFormTemplateControl("txt_OtherPartyName") as ASPxTextBox;
        ASPxComboBox docType        = this.ASPxGridView1.FindEditFormTemplateControl("cbo_DocType") as ASPxComboBox;
        ASPxComboBox docType1       = this.ASPxGridView1.FindEditFormTemplateControl("cbo_DocType1") as ASPxComboBox;

        ASPxTextBox  docN    = this.ASPxGridView1.FindEditFormTemplateControl("txt_DocNo") as ASPxTextBox;
        ASPxDateEdit docDate = this.ASPxGridView1.FindEditFormTemplateControl("txt_DocDt") as ASPxDateEdit;
        ASPxMemo     remark  = this.ASPxGridView1.FindEditFormTemplateControl("txt_Remarks1") as ASPxMemo;

        ASPxButtonEdit docCurr = this.ASPxGridView1.FindEditFormTemplateControl("txt_Currency") as ASPxButtonEdit;
        ASPxSpinEdit   exRate  = this.ASPxGridView1.FindEditFormTemplateControl("txt_DocExRate") as ASPxSpinEdit;
        ASPxButtonEdit acCode  = this.ASPxGridView1.FindEditFormTemplateControl("txt_AcCode") as ASPxButtonEdit;

        ASPxTextBox  slipNo   = this.ASPxGridView1.FindEditFormTemplateControl("txt_SlipNo") as ASPxTextBox;
        ASPxTextBox  bankName = this.ASPxGridView1.FindEditFormTemplateControl("txt_BankName") as ASPxTextBox;
        ASPxTextBox  acDorc   = this.ASPxGridView1.FindEditFormTemplateControl("txt_AcDorc") as ASPxTextBox;
        ASPxTextBox  chqNo    = this.ASPxGridView1.FindEditFormTemplateControl("txt_ChequeNo") as ASPxTextBox;
        ASPxDateEdit chqDt    = this.ASPxGridView1.FindEditFormTemplateControl("txt_ChqDt") as ASPxDateEdit;
        ASPxTextBox  pic      = this.ASPxGridView1.FindEditFormTemplateControl("txt_Pic") as ASPxTextBox;

        ASPxSpinEdit docAmt   = this.ASPxGridView1.FindEditFormTemplateControl("spin_DocAmt") as ASPxSpinEdit;
        ASPxCheckBox isReturn = this.ASPxGridView1.FindEditFormTemplateControl("ck_IsReturn") as ASPxCheckBox;
        C2.pay_doc   inv      = Manager.ORManager.GetObject(typeof(pay_doc), SafeValue.SafeInt(oidCtr.Text, 0)) as pay_doc;
        if (null == inv)// first insert invoice
        {
            //string invN = C2Setup.GetNextNo("AR-RECEIPT");
            inv         = new C2.pay_doc();
            inv.PartyTo = SafeValue.SafeString(partyTo.Value, "");
            //inv.DocNo = invN;
            inv.DocType     = docType.Value.ToString();
            inv.DocType1    = docType1.Value.ToString();
            inv.DocDate     = docDate.Date;
            inv.ChqDate     = chqDt.Date;
            inv.Remark      = remark.Text;
            inv.DocCurrency = docCurr.Text.ToString();
            inv.DocExRate   = SafeValue.SafeDecimal(exRate.Value, 1);
            if (inv.DocExRate <= 0)
            {
                inv.DocExRate = 1;
            }
            inv.AcCode    = acCode.Text;
            inv.BankName  = bankName.Text;
            inv.SlipNo    = slipNo.Text;
            inv.ChqNo     = chqNo.Text;
            inv.ExportInd = "N";

            if (inv.DocType1.ToLower() == "refund")
            {
                inv.AcSource = "CR";
            }
            else
            {
                inv.AcSource = "DB";
            }

            inv.DocAmt         = SafeValue.SafeDecimal(docAmt.Value, 0);
            inv.LocAmt         = inv.DocAmt * inv.DocExRate;
            inv.CancelDate     = new DateTime(1900, 1, 1);
            inv.CancelInd      = "N";
            inv.BankRec        = "N";
            inv.BankDate       = new DateTime(1900, 1, 1);
            inv.OtherPartyName = otherPartyName.Text;
            string[] currentPeriod = EzshipHelper.GetAccPeriod(docDate.Date);
            inv.AcYear   = SafeValue.SafeInt(currentPeriod[1], docDate.Date.Year);
            inv.AcPeriod = SafeValue.SafeInt(currentPeriod[0], docDate.Date.Month);
            inv.Pic      = pic.Text;
            inv.IsReturn = isReturn.Checked;
            try
            {
                inv.GenerateInd    = "N";
                inv.CreateBy       = HttpContext.Current.User.Identity.Name;
                inv.CreateDateTime = DateTime.Now;
                inv.UpdateBy       = HttpContext.Current.User.Identity.Name;
                inv.UpdateDateTime = DateTime.Now;
                inv.PostBy         = "";
                inv.PostDateTime   = new DateTime(1900, 1, 1);
                C2.Manager.ORManager.StartTracking(inv, Wilson.ORMapper.InitialState.Inserted);
                C2.Manager.ORManager.PersistChanges(inv);
                inv.DocNo = inv.Id.ToString();
                C2.Manager.ORManager.StartTracking(inv, Wilson.ORMapper.InitialState.Updated);
                C2.Manager.ORManager.PersistChanges(inv);
                //C2Setup.SetNextNo("AR-RECEIPT", invN);
            }
            catch
            {
            }
        }
        else
        {
            inv.PartyTo     = SafeValue.SafeString(partyTo.Value, "");
            inv.DocDate     = docDate.Date;
            inv.ChqDate     = chqDt.Date;
            inv.Remark      = remark.Text;
            inv.DocCurrency = docCurr.Text.ToString();
            inv.DocExRate   = SafeValue.SafeDecimal(exRate.Value, 1);
            if (inv.DocExRate <= 0)
            {
                inv.DocExRate = 1;
            }
            inv.AcCode   = acCode.Text;
            inv.BankName = bankName.Text;
            inv.SlipNo   = slipNo.Text;
            inv.ChqNo    = chqNo.Text;
            inv.DocAmt   = SafeValue.SafeDecimal(docAmt.Value, 0);
            inv.LocAmt   = inv.DocAmt * inv.DocExRate;
            string[] currentPeriod = EzshipHelper.GetAccPeriod(docDate.Date);
            inv.AcYear   = SafeValue.SafeInt(currentPeriod[1], docDate.Date.Year);
            inv.AcPeriod = SafeValue.SafeInt(currentPeriod[0], docDate.Date.Month);

            inv.OtherPartyName = otherPartyName.Text;
            inv.Pic            = pic.Text;
            inv.IsReturn       = isReturn.Checked;
            try
            {
                inv.UpdateBy       = HttpContext.Current.User.Identity.Name;
                inv.UpdateDateTime = DateTime.Now;
                Manager.ORManager.StartTracking(inv, InitialState.Updated);
                Manager.ORManager.PersistChanges(inv);
            }
            catch
            { }
        }
        Session["ArRecWhere"]             = "Id=" + inv.Id;
        this.dsArReceipt.FilterExpression = Session["ArRecWhere"].ToString();
        if (this.ASPxGridView1.GetRow(0) != null)
        {
            this.ASPxGridView1.StartEdit(0);
        }
        #endregion
    }
Beispiel #23
0
 public void FilldataSource_DataBind_Dev(Control Ctrl, string Sqlstr, object LinQ, Boolean ActivePropertyGrid)
 {
     if (_Conexion.State == ConnectionState.Closed)
     {
         _Conexion.Open();
     }
     if (Sqlstr != "")
     {
         SqlDataAdapter MysqlAdapter = new SqlDataAdapter(Sqlstr, _Conexion);
         DataSet        Mydataset    = new DataSet();
         MysqlAdapter.Fill(Mydataset);
         if (Ctrl is ASPxGridView)
         {
             ASPxGridView Ctrl1 = (ASPxGridView)Ctrl;
             Ctrl1.DataSource = Mydataset.Tables[0];
         }
         if (Ctrl is ASPxGridLookup)
         {
             ASPxGridLookup Ctrl1 = (ASPxGridLookup)Ctrl;
             Ctrl1.DataSource = Mydataset.Tables[0];
         }
         if (Ctrl is ASPxComboBox)
         {
             ASPxComboBox Ctrl1 = (ASPxComboBox)Ctrl;
             Ctrl1.DataSource = Mydataset.Tables[0];
         }
         if (Ctrl is BootstrapComboBox)
         {
             BootstrapComboBox Ctrl1 = (BootstrapComboBox)Ctrl;
             Ctrl1.DataSource = Mydataset.Tables[0];
         }
     }
     else
     {
         if (Ctrl is ASPxGridView)
         {
             ASPxGridView Ctrl1 = (ASPxGridView)Ctrl;
             Ctrl1.DataSource = LinQ;
         }
         if (Ctrl is ASPxGridLookup)
         {
             ASPxGridLookup Ctrl1 = (ASPxGridLookup)Ctrl;
             Ctrl1.DataSource = LinQ;
         }
         if (Ctrl is ASPxComboBox)
         {
             ASPxComboBox Ctrl1 = (ASPxComboBox)Ctrl;
             Ctrl1.DataSource = LinQ;
         }
         if (Ctrl is BootstrapComboBox)
         {
             BootstrapComboBox Ctrl1 = (BootstrapComboBox)Ctrl;
             Ctrl1.DataSource = LinQ;
         }
     }
     if (ActivePropertyGrid == false)
     {
         if (Ctrl is ASPxGridView)
         {
             ASPxGridView Ctrl1 = (ASPxGridView)Ctrl;
             Ctrl1.DataBind();
         }
         if (Ctrl is ASPxGridLookup)
         {
             ASPxGridLookup Ctrl1 = (ASPxGridLookup)Ctrl;
             Ctrl1.DataBind();
         }
         if (Ctrl is ASPxComboBox)
         {
             ASPxComboBox Ctrl1 = (ASPxComboBox)Ctrl;
             Ctrl1.DataBind();
         }
         if (Ctrl is BootstrapComboBox)
         {
             BootstrapComboBox Ctrl1 = (BootstrapComboBox)Ctrl;
             Ctrl1.DataBind();
         }
     }
     _Conexion.Close();
 }
Beispiel #24
0
    protected void ASPxGridView1_CustomDataCallback(object sender, ASPxGridViewCustomDataCallbackEventArgs e)
    {
        string      filter = e.Parameters;
        ASPxTextBox oidCtr = this.ASPxGridView1.FindEditFormTemplateControl("txt_Oid") as ASPxTextBox;

        //ASPxTextBox docN = this.ASPxGridView1.FindEditFormTemplateControl("txt_DocNo") as ASPxTextBox;

        if (filter == "P")
        {
            SaveBill();
            #region Post
            string sql = @"SELECT AcYear, AcPeriod, DocType, DocNo, DocDate, DocCurrency, DocExRate, PartyTo, OtherPartyName, DocAmt, LocAmt, AcCode, AcSource, ChqNo, ChqDate, ExportInd, 
                      BankName, Remark,GenerateInd FROM  pay_doc";
            sql += " WHERE Id='" + oidCtr.Text + "'";
            DataTable dt             = Manager.ORManager.GetDataSet(sql).Tables[0];
            int       acYear         = 0;
            int       acPeriod       = 0;
            string    docN           = "";
            string    docType        = "";
            string    acSource       = "";
            string    acCode         = "";
            decimal   locAmt         = 0;
            decimal   docAmt         = 0;
            decimal   exRate         = 0;
            string    currency       = "";
            DateTime  docDt          = DateTime.Today;
            string    remarks        = "";
            string    partyTo        = "";
            string    otherPartyName = "";
            string    chqNo          = "";
            string    generateInd    = "";
            if (dt.Rows.Count == 1)
            {
                acYear   = SafeValue.SafeInt(dt.Rows[0]["AcYear"], 0);
                acPeriod = SafeValue.SafeInt(dt.Rows[0]["AcPeriod"], 0);
                acSource = dt.Rows[0]["AcSource"].ToString();
                acCode   = dt.Rows[0]["AcCode"].ToString();
                docN     = dt.Rows[0]["DocNo"].ToString();
                docType  = dt.Rows[0]["DocType"].ToString();
                locAmt   = SafeValue.SafeDecimal(dt.Rows[0]["LocAmt"].ToString(), 0);
                docAmt   = SafeValue.SafeDecimal(dt.Rows[0]["DocAmt"].ToString(), 0);
                exRate   = SafeValue.SafeDecimal(dt.Rows[0]["DocExRate"].ToString(), 0);
                currency = dt.Rows[0]["DocCurrency"].ToString();
                docDt    = SafeValue.SafeDate(dt.Rows[0]["DocDate"], new DateTime(1900, 1, 1));
                // partyId = dt.Rows[0][""].ToString();
                remarks        = dt.Rows[0]["Remark"].ToString();
                partyTo        = dt.Rows[0]["PartyTo"].ToString();
                otherPartyName = dt.Rows[0]["OtherPartyName"].ToString();
                chqNo          = dt.Rows[0]["ChqNo"].ToString();
                generateInd    = SafeValue.SafeString(dt.Rows[0]["GenerateInd"]);
            }
            else
            {
                e.Result = "Can't find the ArReceipt!";
                return;
            }
            if (generateInd.ToUpper() != "Y")
            {
                e.Result = "Have not generate no!";
                return;
            }

            string sqlDet = string.Format("select count(Id) from pay_line where RepId='{0}'", oidCtr.Text);
            int    detCnt = SafeValue.SafeInt(Manager.ORManager.ExecuteScalar(sqlDet), 0);
            if (detCnt == 0)
            {
                e.Result = "No Detail, Can't Post";
                return;
            }
            sqlDet = string.Format("select max(docDate) from pay_line where RepId='{0}'", oidCtr.Text);
            DateTime maxLineDocDate = SafeValue.SafeDate(Manager.ORManager.ExecuteScalar(sqlDet), new DateTime(1900, 1, 1));
            if (maxLineDocDate > new DateTime(2000, 1, 1) && maxLineDocDate > docDt)
            {
                e.Result = "The bill's Date can't be greater than receipt date.";
                return;
            }

            //check account period
            if (acYear < 1 || acPeriod < 1)
            {
                e.Result = "Account year or Period Invalid!";
                return;
            }
            string sql1     = "select CloseInd from XXAccPeriod where Year='" + acYear + "' and Period ='" + acPeriod + "'";
            string closeInd = SafeValue.SafeString(Manager.ORManager.ExecuteScalar(sql1), "");
            if (closeInd == "")
            {
                e.Result = "Can't find this account period!";
                return;
            }
            else if (closeInd == "Y")
            {
                e.Result = "The account period is closed!";
                return;
            }
            //mast.amt det.amt is match
            sql = string.Format("select sum(locamt) from pay_line where RepId='{0}' and AcSource='CR'", oidCtr.Text);
            decimal amt_detCr = SafeValue.SafeDecimal(Manager.ORManager.ExecuteScalar(sql), 0);
            sql = string.Format("select sum(locamt) from pay_line where RepId='{0}' and AcSource='DB'", oidCtr.Text);
            decimal amt_detDb = SafeValue.SafeDecimal(Manager.ORManager.ExecuteScalar(sql), 0);
            if (docType == "RE" && locAmt != amt_detCr - amt_detDb)
            {
                e.Result = "Amount can't match, can't post";
                return;
            }
            else if (docType == "PC" && locAmt != -amt_detCr + amt_detDb)
            {
                e.Result = "Amount can't match, can't post";
                return;
            }

            sql    = "select count(*) from pay_line where AcCode='' and RepId='" + oidCtr.Text + "'";
            detCnt = SafeValue.SafeInt(C2.Manager.ORManager.ExecuteScalar(sql), 0);
            if (detCnt > 0)
            {
                e.Result = "Some Item's Accode is blank, pls check";
                return;
            }
            //delete old post data
            sql = string.Format("SELECT SequenceId from XAGlEntry WHERE DocNo='{0}' and DocType='{1}'", docN, docType);
            int glOldOid = SafeValue.SafeInt(Manager.ORManager.ExecuteScalar(sql), 0);
            if (glOldOid > 0)
            {
                DeleteGl(glOldOid);
            }

            //Insert into gl entry
            int glOid = 0;
            try
            {
                C2.XAGlEntry gl = new XAGlEntry();
                gl.AcPeriod         = acPeriod;
                gl.AcYear           = acYear;
                gl.ArApInd          = "AR";
                gl.DocType          = docType;
                gl.DocDate          = docDt;
                gl.DocNo            = docN;
                gl.CrAmt            = docAmt;
                gl.DbAmt            = docAmt;
                gl.CurrencyCrAmt    = locAmt;
                gl.CurrencyDbAmt    = locAmt;
                gl.CurrencyId       = currency;
                gl.EntryDate        = DateTime.Now;
                gl.ExRate           = exRate;
                gl.PostDate         = DateTime.Now;
                gl.PostInd          = "N";
                gl.Remark           = remarks;
                gl.UserId           = HttpContext.Current.User.Identity.Name;
                gl.CancelInd        = "N";
                gl.CancelDate       = new DateTime(1900, 1, 1);
                gl.PartyTo          = partyTo;
                gl.OtherPartyName   = otherPartyName;
                gl.ChqNo            = chqNo;
                gl.SupplierBillNo   = "";
                gl.SupplierBillDate = new DateTime(1900, 1, 1);
                Manager.ORManager.StartTracking(gl, InitialState.Inserted);
                Manager.ORManager.PersistChanges(gl);
                glOid = gl.SequenceId;

                //insert Detail
                OPathQuery   query = new OPathQuery(typeof(pay_line), "RepId='" + oidCtr.Text + "'");
                ObjectSet    set   = Manager.ORManager.GetObjectSet(query);
                int          index = 1;
                XAGlEntryDet det1  = new XAGlEntryDet();

                det1.AcCode        = acCode;
                det1.ArApInd       = "AR";
                det1.AcPeriod      = acPeriod;
                det1.AcSource      = acSource;
                det1.AcYear        = acYear;
                det1.CrAmt         = 0;
                det1.CurrencyCrAmt = 0;
                det1.DbAmt         = docAmt;
                det1.CurrencyDbAmt = locAmt;
                det1.CurrencyId    = currency;
                det1.DocNo         = docN;
                det1.DocType       = docType;
                det1.ExRate        = exRate;
                det1.GlLineNo      = index;
                det1.GlNo          = gl.SequenceId;
                det1.Remark        = remarks;


                Manager.ORManager.StartTracking(det1, InitialState.Inserted);
                Manager.ORManager.PersistChanges(det1);
                for (int i = 0; i < set.Count; i++)
                {
                    try
                    {
                        index++;
                        pay_line     invDet = set[i] as pay_line;
                        XAGlEntryDet det    = new XAGlEntryDet();

                        det.AcCode   = invDet.AcCode;
                        det.ArApInd  = "AR";
                        det.AcPeriod = acPeriod;
                        det.AcSource = invDet.AcSource;
                        det.AcYear   = acYear;
                        if (invDet.AcSource == "DB")
                        {
                            det.DbAmt         = invDet.DocAmt;
                            det.CurrencyDbAmt = invDet.LocAmt;
                            det.CrAmt         = 0;
                            det.CurrencyCrAmt = 0;
                        }
                        else// if (det.AcSource == "CR")
                        {
                            det.CrAmt         = invDet.DocAmt;
                            det.CurrencyCrAmt = invDet.LocAmt;
                            det.DbAmt         = 0;
                            det.CurrencyDbAmt = 0;
                        }
                        det.CurrencyId = invDet.Currency;

                        det.DocNo    = docN;
                        det.DocType  = docType;
                        det.ExRate   = invDet.ExRate;
                        det.GlLineNo = index;
                        det.GlNo     = gl.SequenceId;
                        det.Remark   = invDet.Remark1;


                        Manager.ORManager.StartTracking(det, InitialState.Inserted);
                        Manager.ORManager.PersistChanges(det);
                    }
                    catch
                    {
                        e.Result = "Posting Error, Please repost!";
                        DeleteGl(glOid);
                    }
                }
                UpdateArInv(oidCtr.Text);
                EzshipLog.Log(docN, "", docType, "Post");
                e.Result = "Post completely!";
            }
            catch
            {
                e.Result = "Posting Error, Please repost!";
                DeleteGl(glOid);
            }
            #endregion
        }
        else if (filter == "DD")
        {
            #region delete receipt

            try
            {
                string    sql = "SELECT Id,DocId, DocType FROM pay_line where RepId ='" + oidCtr.Text + "'";
                DataTable tab = C2.Manager.ORManager.GetDataSet(sql).Tables[0];
                for (int i = 0; i < tab.Rows.Count; i++)
                {
                    try
                    {
                        string id      = tab.Rows[i]["Id"].ToString();
                        string docId   = tab.Rows[i]["DocId"].ToString();
                        string docType = tab.Rows[i]["DocType"].ToString();
                        string sql_det = "delete from pay_line where Id='" + id + "'";
                        if (C2.Manager.ORManager.ExecuteCommand(sql_det) > 0)
                        {
                            UpdateMaster(docId, docType);
                        }
                    }
                    catch (Exception ex)
                    {
                        throw new Exception(ex.Message);
                    }
                }
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
            #endregion
        }
        else if (filter == "Reverse")
        {
            #region reverse receipt 0:period is closed? 1:unpost 2:exportind='N' 3: delete all item

            try
            {
                string sql1 = string.Format("select CloseInd from xxaccperiod where Year=(select AcYear from pay_doc where Id='{0}') and Period=(select top(1)AcPeriod from pay_doc where SequenceId='{0}')", oidCtr.Text);
                if (SafeValue.SafeString(ConnectSql.ExecuteScalar(sql1)) != "N")
                {
                    throw new Exception("Acc Period is Closed!");
                }
                string sql_invoice = string.Format("select sequenceid from xaglentry where ArApInd='AR' and docno=(select docno from pay_doc where id='{0}') and DocType=(select doctype from pay_doc where id='{0}') ", oidCtr.Text);
                DeleteGl(SafeValue.SafeInt(ConnectSql.ExecuteScalar(sql_invoice), 0));

                sql_invoice = "update pay_doc set IsReturn='true', ExportInd='N' where Id='" + oidCtr.Text + "'";
                Manager.ORManager.ExecuteCommand(sql_invoice);

                string    sql = "SELECT Id,DocId, DocType FROM pay_line where RepId ='" + oidCtr.Text + "'";
                DataTable tab = C2.Manager.ORManager.GetDataSet(sql).Tables[0];
                for (int i = 0; i < tab.Rows.Count; i++)
                {
                    try
                    {
                        string id      = tab.Rows[i]["Id"].ToString();
                        string docId   = tab.Rows[i]["DocId"].ToString();
                        string docType = tab.Rows[i]["DocType"].ToString();
                        string sql_det = "delete from pay_line where Id='" + id + "'";
                        if (C2.Manager.ORManager.ExecuteCommand(sql_det) > 0)
                        {
                            UpdateMaster(docId, docType);
                        }
                    }
                    catch (Exception ex)
                    {
                        throw new Exception(ex.Message);
                    }
                }
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
            #endregion
        }
        else if (filter == "GainLoss")
        {
            #region GAIN LOSS
            ASPxComboBox docType = this.ASPxGridView1.FindEditFormTemplateControl("cbo_DocType") as ASPxComboBox;
            string       sql     = string.Format("select (select LocAmt from pay_doc where Id='{0}')-iSNULL(sum(case when AcSource='CR' then -LocAmt else LocAmt end),0) As LocAmt from pay_line where repid='{0}'", oidCtr.Text);
            if (docType.Text == "RE")
            {
                sql = string.Format("select (select LocAmt from pay_doc where Id='{0}')-iSNULL(sum(case when AcSource='DB' then -LocAmt else LocAmt end),0) As LocAmt from pay_line where repid='{0}'", oidCtr.Text);
            }
            decimal balAmt = SafeValue.SafeDecimal(C2.Manager.ORManager.ExecuteScalar(sql), 0);
            if (balAmt > 0)
            {
                string   gainAccCode = System.Configuration.ConfigurationManager.AppSettings["GainLoseAcCode"];
                pay_line det         = new pay_line();
                det.AcCode = gainAccCode;
                if (docType.Text == "RE")
                {
                    det.AcSource = "CR";
                }
                else
                {
                    det.AcSource = "DB";
                }
                det.DocType  = docType.Text;
                det.RepType  = docType.Text;
                det.Currency = System.Configuration.ConfigurationManager.AppSettings["Currency"];
                det.DocAmt   = balAmt;
                det.DocDate  = new DateTime(1900, 1, 1);
                det.DocId    = 0;
                det.DocNo    = "";
                det.ExRate   = 1;
                det.LocAmt   = balAmt;
                det.Remark1  = "GAIN AND LOSS";
                det.Remark2  = "";
                det.Remark3  = "";
                det.RepId    = SafeValue.SafeInt(oidCtr.Text, 0);
                ASPxTextBox docN = this.ASPxGridView1.FindEditFormTemplateControl("txt_DocNo") as ASPxTextBox;
                det.RepNo = docN.Text;
                string sql_detCnt = "select count(DocNo) from pay_line where RepId='" + oidCtr.Text + "'";
                int    lineNo     = SafeValue.SafeInt(Manager.ORManager.ExecuteScalar(sql_detCnt), 0) + 1;
                det.RepLineNo = lineNo;
                C2.Manager.ORManager.StartTracking(det, Wilson.ORMapper.InitialState.Inserted);
                C2.Manager.ORManager.PersistChanges(det);
            }
            else if (balAmt < 0)
            {
                string   gainAccCode = System.Configuration.ConfigurationManager.AppSettings["GainLoseAcCode"];
                pay_line det         = new pay_line();
                det.AcCode = gainAccCode;
                if (docType.Text == "RE")
                {
                    det.AcSource = "DB";
                }
                else
                {
                    det.AcSource = "CR";
                }
                det.DocType  = docType.Text;
                det.RepType  = docType.Text;
                det.Currency = System.Configuration.ConfigurationManager.AppSettings["Currency"];
                det.DocAmt   = -balAmt;
                det.DocDate  = new DateTime(1900, 1, 1);
                det.DocId    = 0;
                det.DocNo    = "";
                det.ExRate   = 1;
                det.LocAmt   = -balAmt;
                det.Remark1  = "GAIN AND LOSS";
                det.Remark2  = "";
                det.Remark3  = "";
                det.RepId    = SafeValue.SafeInt(oidCtr.Text, 0);
                ASPxTextBox docN = this.ASPxGridView1.FindEditFormTemplateControl("txt_DocNo") as ASPxTextBox;
                det.RepNo = docN.Text;
                string sql_detCnt = "select count(DocNo) from pay_line where RepId='" + oidCtr.Text + "'";
                int    lineNo     = SafeValue.SafeInt(Manager.ORManager.ExecuteScalar(sql_detCnt), 0) + 1;
                det.RepLineNo = lineNo;
                C2.Manager.ORManager.StartTracking(det, Wilson.ORMapper.InitialState.Inserted);
                C2.Manager.ORManager.PersistChanges(det);
            }
            #endregion
        }
        else if (filter == "Generate")
        {
            string    sql = @"SELECT DocType, DocDate FROM  pay_doc WHERE Id='" + oidCtr.Text + "'";
            DataTable dt  = Manager.ORManager.GetDataSet(sql).Tables[0];
            if (dt.Rows.Count == 1)
            {
                DateTime docDate = SafeValue.SafeDate(dt.Rows[0]["DocDate"], DateTime.Today);
                string   docType = SafeValue.SafeString(dt.Rows[0]["DocType"]);

                string invN = C2Setup.GetNextNo(docType, "AR-RECEIPT", docDate);
                sql = string.Format("Update pay_doc set DocNo='{1}',GenerateInd='Y' where Id='{0}'", oidCtr.Text, invN);
                if (ConnectSql.ExecuteSql(sql) > -1)
                {
                    C2Setup.SetNextNo(docType, "AR-RECEIPT", invN, docDate);
                }
                e.Result = invN;
            }
        }
    }
Beispiel #25
0
        protected void GridOrderDetail_CustomCallback(object sender, ASPxGridViewCustomCallbackEventArgs e)
        {
            string[] parameter = e.Parameters.Split(':');

            switch (parameter[0])
            {
            case ("Save"):

                int rowKey;
                int intSortShipper = 0;
                int intQuantity    = 0;
                int intShipper     = 0;

                for (int i = 0; i < GridOrderDetail.VisibleRowCount; i++)
                {
                    rowKey = Convert.ToInt32(GridOrderDetail.GetRowValues(Convert.ToInt32(i), "OrderDetailID"));

                    if (GridOrderDetail.IsGroupRow(i))
                    {
                        ASPxSpinEdit spinSortShipper = (ASPxSpinEdit)GridOrderDetail.FindGroupRowTemplateControl(i, "spinSortShipper");
                        ((IPostBackDataHandler)spinSortShipper).LoadPostData("spinSortShipper", Request.Form);
                        intSortShipper = Convert.ToInt32(spinSortShipper.Value);

                        ASPxComboBox cboShipper = (ASPxComboBox)GridOrderDetail.FindGroupRowTemplateControl(i, "cboShipper");
                        ((IPostBackDataHandler)cboShipper).LoadPostData("cboShipper", Request.Form);
                        intShipper = Convert.ToInt32(cboShipper.Value);

                        ASPxSpinEdit spinQuantity = (ASPxSpinEdit)GridOrderDetail.FindGroupRowTemplateControl(i, "spinQuantity");
                        ((IPostBackDataHandler)spinQuantity).LoadPostData("spinQuantity", Request.Form);
                        intQuantity = Convert.ToInt32(spinQuantity.Value);
                    }
                    if (!GridOrderDetail.IsGroupRow(i))
                    {
                        ASPxComboBox cboProduct = (ASPxComboBox)GridOrderDetail.FindRowCellTemplateControl(i, (GridViewDataComboBoxColumn)GridOrderDetail.Columns["ProductID"], "cboProduct");
                        ((IPostBackDataHandler)cboProduct).LoadPostData("cboProduct", Request.Form);

                        ASPxSpinEdit spinSortProduct = (ASPxSpinEdit)GridOrderDetail.FindRowCellTemplateControl(i, (GridViewDataSpinEditColumn)GridOrderDetail.Columns["SortProduct"], "spinSortProduct");
                        ((IPostBackDataHandler)spinSortProduct).LoadPostData("spinSortProduct", Request.Form);

                        ASPxSpinEdit spinDefaultPrice = (ASPxSpinEdit)GridOrderDetail.FindRowCellTemplateControl(i, (GridViewDataSpinEditColumn)GridOrderDetail.Columns["DefaultPrice"], "spinDefaultPrice");
                        ((IPostBackDataHandler)spinDefaultPrice).LoadPostData("spinDefaultPrice", Request.Form);

                        ASPxSpinEdit spinUnitPrice = (ASPxSpinEdit)GridOrderDetail.FindRowCellTemplateControl(i, (GridViewDataSpinEditColumn)GridOrderDetail.Columns["UnitPrice"], "spinUnitPrice");
                        ((IPostBackDataHandler)spinUnitPrice).LoadPostData("spinUnitPrice", Request.Form);

                        ASPxSpinEdit spinDiscount = (ASPxSpinEdit)GridOrderDetail.FindRowCellTemplateControl(i, (GridViewDataSpinEditColumn)GridOrderDetail.Columns["Discount"], "spinDiscount");
                        ((IPostBackDataHandler)spinDiscount).LoadPostData("spinDiscount", Request.Form);

                        ASPxSpinEdit spinIncrease = (ASPxSpinEdit)GridOrderDetail.FindRowCellTemplateControl(i, (GridViewDataSpinEditColumn)GridOrderDetail.Columns["Increase"], "spinIncrease");
                        ((IPostBackDataHandler)spinIncrease).LoadPostData("spinIncrease", Request.Form);

                        ASPxSpinEdit spinRowTotal = (ASPxSpinEdit)GridOrderDetail.FindRowCellTemplateControl(i, (GridViewDataSpinEditColumn)GridOrderDetail.Columns["TotalPrice"], "spinRowTotal");
                        ((IPostBackDataHandler)spinRowTotal).LoadPostData("spinRowTotal", Request.Form);

                        ASPxSpinEdit spinRowTotalCustomer = (ASPxSpinEdit)GridOrderDetail.FindRowCellTemplateControl(i, (GridViewDataSpinEditColumn)GridOrderDetail.Columns["TotalCustomer"], "spinRowTotalCustomer");
                        ((IPostBackDataHandler)spinRowTotalCustomer).LoadPostData("spinRowTotalCustomer", Request.Form);

                        SqlCommand comm = new SqlCommand();
                        comm.Connection = con;

                        comm.CommandText = "update OrderDetails set SortProduct = @SortProduct, DefaultPrice = @DefaultPrice, UnitPrice = @UnitPrice,Discount = @Discount, Increase = @Increase, TotalPrice = @TotalPrice, TotalCustomer = @TotalCustomer, SortShipper = @SortShipper, Quantity = @Quantity, ShipperID = @ShipperID, ProductID = @ProductID " +
                                           "where OrderDetailID = @OrderDetailID";

                        comm.Parameters.AddWithValue("@OrderDetailID", rowKey);

                        comm.Parameters.AddWithValue("@ShipperID", Convert.ToInt32(intShipper));
                        comm.Parameters.AddWithValue("@SortShipper", Convert.ToInt32(intSortShipper));
                        comm.Parameters.AddWithValue("@Quantity", Convert.ToInt32(intQuantity));

                        comm.Parameters.AddWithValue("@ProductID", Convert.ToInt32(cboProduct.Value));
                        comm.Parameters.AddWithValue("@SortProduct", Convert.ToInt32(spinSortProduct.Value));
                        comm.Parameters.AddWithValue("@DefaultPrice", Convert.ToDouble(spinDefaultPrice.Value));
                        comm.Parameters.AddWithValue("@UnitPrice", Convert.ToDouble(spinUnitPrice.Value));
                        comm.Parameters.AddWithValue("@Discount", Convert.ToDouble(spinDiscount.Value));
                        comm.Parameters.AddWithValue("@Increase", Convert.ToDouble(spinIncrease.Value));
                        comm.Parameters.AddWithValue("@TotalPrice", Convert.ToDouble(spinRowTotal.Value));
                        comm.Parameters.AddWithValue("@TotalCustomer", Convert.ToDouble(spinRowTotalCustomer.Value));

                        con.Open();
                        comm.ExecuteNonQuery();
                        con.Close();
                    }
                }

                ASPxSpinEdit spinDiscountTotal = (ASPxSpinEdit)GridOrderDetail.FindFooterCellTemplateControl((GridViewDataSpinEditColumn)GridOrderDetail.Columns["Discount"], "spinDiscountTotal");
                ((IPostBackDataHandler)spinDiscountTotal).LoadPostData("spinDiscountTotal", Request.Form);

                ASPxSpinEdit spinIncreaseTotal = (ASPxSpinEdit)GridOrderDetail.FindFooterCellTemplateControl((GridViewDataSpinEditColumn)GridOrderDetail.Columns["Increase"], "spinIncreaseTotal");
                ((IPostBackDataHandler)spinIncreaseTotal).LoadPostData("spinIncreaseTotal", Request.Form);

                ASPxSpinEdit spinGrandTotal = (ASPxSpinEdit)GridOrderDetail.FindFooterCellTemplateControl((GridViewDataSpinEditColumn)GridOrderDetail.Columns["TotalPrice"], "spinGrandTotal");
                ((IPostBackDataHandler)spinGrandTotal).LoadPostData("spinGrandTotal", Request.Form);

                ASPxSpinEdit spinGrandTotalCustomer = (ASPxSpinEdit)GridOrderDetail.FindFooterCellTemplateControl((GridViewDataSpinEditColumn)GridOrderDetail.Columns["TotalCustomer"], "spinGrandTotalCustomer");
                ((IPostBackDataHandler)spinGrandTotalCustomer).LoadPostData("spinGrandTotalCustomer", Request.Form);

                SqlCommand commTotal = new SqlCommand();
                commTotal.Connection  = con;
                commTotal.CommandText = "update Orders set TotalDiscount = @TotalDiscount, TotalIncrease = @TotalIncrease, GrandTotal = @GrandTotal, TotalCustomer = @TotalCustomer " +
                                        "where OrderID = @OrderID";
                commTotal.Parameters.AddWithValue("@OrderID", Convert.ToInt32(Request.Params["OrderID"]));
                commTotal.Parameters.AddWithValue("@TotalDiscount", Convert.ToDouble(spinDiscountTotal.Value));
                commTotal.Parameters.AddWithValue("@TotalIncrease", Convert.ToDouble(spinIncreaseTotal.Value));
                commTotal.Parameters.AddWithValue("@GrandTotal", Convert.ToDouble(spinGrandTotal.Value));
                commTotal.Parameters.AddWithValue("@TotalCustomer", Convert.ToDouble(spinGrandTotalCustomer.Value));

                con.Open();
                commTotal.ExecuteNonQuery();
                con.Close();

                GridOrderDetail.DataBind();

                switch (parameter[1])
                {
                case ("New"):
                    GridOrderDetail.AddNewRow();
                    break;
                }

                break;
            }
        }
    protected void SavePrice()
    {
        try
        {
            ASPxPageControl            pageControl = this.grid_Price.FindEditFormTemplateControl("pageControl_Hbl") as ASPxPageControl;
            ASPxTextBox                txt_Id      = grid_Price.FindEditFormTemplateControl("txt_Id") as ASPxTextBox;
            string                     pId         = SafeValue.SafeString(txt_Id.Text, "");
            Wilson.ORMapper.OPathQuery query       = new Wilson.ORMapper.OPathQuery(typeof(WhTrans), "Id='" + pId + "'");
            WhTrans                    whTrans     = C2.Manager.ORManager.GetObject(query) as WhTrans;
            ASPxDateEdit               issueDate   = grid_Price.FindEditFormTemplateControl("date_IssueDate") as ASPxDateEdit;
            bool isNew = false;
            //const string runType = "DOOUT";
            string issueN = "";
            if (whTrans == null)
            {
                whTrans        = new WhTrans();
                isNew          = true;
                issueN         = C2Setup.GetNextNo("", "SalePrice", issueDate.Date);
                whTrans.DoDate = issueDate.Date;
            }

            ASPxDateEdit doDate = grid_Price.FindEditFormTemplateControl("date_IssueDate") as ASPxDateEdit;
            whTrans.DoDate = doDate.Date;
            ASPxDateEdit txt_ExpectedDate = this.grid_Price.FindEditFormTemplateControl("txt_ExpectedDate") as ASPxDateEdit;
            whTrans.ExpectedDate = txt_ExpectedDate.Date;

            ASPxComboBox doStatus = grid_Price.FindEditFormTemplateControl("cmb_Status") as ASPxComboBox;
            whTrans.DoStatus = SafeValue.SafeString(doStatus.Value);
            //Main Info
            ASPxButtonEdit txt_PartyId = grid_Price.FindEditFormTemplateControl("txt_PartyId") as ASPxButtonEdit;
            whTrans.PartyId = txt_PartyId.Text;
            ASPxTextBox txt_PartyName = grid_Price.FindEditFormTemplateControl("txt_PartyName") as ASPxTextBox;
            whTrans.PartyName = txt_PartyName.Text;
            if (txt_PartyName.Text == "")
            {
                throw new Exception("Customer not be null!!!");
                return;
            }
            ASPxMemo remark = grid_Price.FindEditFormTemplateControl("txt_Remark") as ASPxMemo;
            whTrans.Remark = remark.Text;
            string userId = HttpContext.Current.User.Identity.Name;
            if (isNew)
            {
                whTrans.StatusCode     = "USE";
                whTrans.CreateBy       = userId;
                whTrans.CreateDateTime = DateTime.Now;
                whTrans.UpdateBy       = userId;
                whTrans.UpdateDateTime = DateTime.Now;
                whTrans.DoType         = "SQ";
                whTrans.DoNo           = issueN;
                Manager.ORManager.StartTracking(whTrans, Wilson.ORMapper.InitialState.Inserted);
                Manager.ORManager.PersistChanges(whTrans);
                C2Setup.SetNextNo("", "SalePrice", issueN, issueDate.Date);
            }
            else
            {
                whTrans.UpdateBy       = userId;
                whTrans.UpdateDateTime = DateTime.Now;
                Manager.ORManager.StartTracking(whTrans, Wilson.ORMapper.InitialState.Updated);
                Manager.ORManager.PersistChanges(whTrans);
            }
            Session["PriceWhere"]         = "DoNo='" + whTrans.DoNo + "'";
            this.dsPrice.FilterExpression = Session["PriceWhere"].ToString();
            if (this.grid_Price.GetRow(0) != null)
            {
                this.grid_Price.StartEdit(0);
            }
        }
        catch { }
    }
Beispiel #27
0
    public static void Set_DDLORG_LV3_BY_LV1_2(ASPxComboBox ddl, string wh)
    {
        try
        {
            string sql = "select ORG_SERIAL,ORG_NAME,ORG_ABBR from vw_SMM_ORG_LEVEL3 where 1=1 ";
            if (wh != "76") { sql += " AND UPPER_ORG_SERIAL = " + wh; }
            sql += " Order by ORG_SERIAL";
            SqlDataAdapter da = new SqlDataAdapter(sql, StaticDefaultConnectionString);
            DataTable dt = new DataTable();
            da.Fill(dt);

            if (dt.Rows.Count > 0)
            {
                ddl.Columns.Clear();

                ddl.ValueField = "ORG_SERIAL";
                ddl.TextField = "ORG_NAME";

                ddl.DataSource = dt;
                ddl.DataBind();
            }
            else
            {
                ddl.Columns.Clear();

                ddl.ValueField = "ORG_SERIAL";
                ddl.TextField = "ORG_NAME";

                ddl.DataSource = dt;
                ddl.DataBind();
            }
        }
        catch (Exception ex)
        {

        }
    }
Beispiel #28
0
        protected void grdFinanceBudgetDet_RowInserting(object sender, DevExpress.Web.Data.ASPxDataInsertingEventArgs e)
        {
            ASPxGridView      grid          = sender as ASPxGridView;
            ASPxComboBox      entCode       = grdFinanceBudgetDet.FindEditRowCellTemplateControl((GridViewDataColumn)grdFinanceBudgetDet.Columns["EntityCodeDesc"], "Entity") as ASPxComboBox;
            ASPxCallbackPanel callBackPanel = grdFinanceBudgetDet.FindEditRowCellTemplateControl((GridViewDataColumn)grdFinanceBudgetDet.Columns["BUSSUCodeDesc"], "FinBUCallbackPanel") as ASPxCallbackPanel;
            ASPxComboBox      buCode        = callBackPanel.FindControl("BUSSU") as ASPxComboBox;

            string sLastModified = DateTime.Now.ToString();

            SqlConnection conn = new SqlConnection(GlobalClass.SQLConnString());

            conn.Open();

            string sBUCode = "";

            if (buCode.Value != null)
            {
                sBUCode = buCode.Value.ToString();
            }

            string insert = "INSERT INTO tbl_System_FinanceBudget_Details ([MasterKey], [EntityCode], [BUSSUCode]) " +
                            " VALUES (@MasterKey, @EntityCode, @BUSSUCode)";

            SqlCommand cmd = new SqlCommand(insert, conn);

            cmd.Parameters.AddWithValue("@MasterKey", iMasterKey.ToString());
            cmd.Parameters.AddWithValue("@EntityCode", entCode.Value.ToString());
            cmd.Parameters.AddWithValue("@BUSSUCode", sBUCode);
            cmd.CommandType = CommandType.Text;
            cmd.ExecuteNonQuery();

            string updateMaster = "UPDATE tbl_System_FinanceBudget " +
                                  " SET [LastModified] = @LastModified " +
                                  " WHERE ([PK] = @PK)";

            SqlCommand cmd1 = new SqlCommand(updateMaster, conn);

            cmd1.Parameters.AddWithValue("@PK", iMasterKey.ToString());
            cmd1.Parameters.AddWithValue("@LastModified", sLastModified.ToString());
            cmd1.CommandType = CommandType.Text;
            cmd1.ExecuteNonQuery();

            e.Cancel = true;
            grid.CancelEdit();
            BindFinanceBudgetDet(iMasterKey);

            int           pk_latest = 0;
            string        query_pk  = "SELECT TOP 1 [PK] FROM tbl_System_FinanceBudget_Details ORDER BY [PK] DESC";
            SqlCommand    comm      = new SqlCommand(query_pk, conn);
            SqlDataReader r         = comm.ExecuteReader();

            while (r.Read())
            {
                pk_latest = Convert.ToInt32(r[0].ToString());
            }
            conn.Close();
            if (pk_latest > 0)
            {
                FocusThisRowGrid(grid, pk_latest);
            }
        }
    protected override void AssignControllerValues()
    {
        ASPxTextBox  tbSubject     = (ASPxTextBox)FindControlByID("tbSubject");
        ASPxTextBox  tbLocation    = (ASPxTextBox)FindControlByID("tbLocation");
        ASPxMemo     tbDescription = (ASPxMemo)FindControlByID("tbDescription");
        ASPxDateEdit edtStartDate  = (ASPxDateEdit)FindControlByID("edtStartDate");
        ASPxDateEdit edtEndDate    = (ASPxDateEdit)FindControlByID("edtEndDate");
        ASPxCheckBox chkAllDay     = (ASPxCheckBox)FindControlByID("chkAllDay");
        ASPxComboBox edtShowTimeAs = (ASPxComboBox)FindControlByID("edtStatus");
        ASPxComboBox edtLabel      = (ASPxComboBox)FindControlByID("edtLabel");
        ASPxCheckBox chkReminder   = (ASPxCheckBox)FindControlByID("chkReminder");
        ASPxComboBox cbReminder    = (ASPxComboBox)FindControlByID("cbReminder");
        Repeater     rpResources   = (Repeater)FindControlByID("rpResources");
        DateTime     clientStart   = DateTime.MinValue;
        DateTime     clientEnd     = DateTime.MinValue;

        if (edtStartDate != null)
        {
            clientStart = FromClientTime(edtStartDate.Date);
            Controller.EditedAppointmentCopy.Start = clientStart;
        }
        if (edtEndDate != null)
        {
            clientEnd = FromClientTime(edtEndDate.Date);
            Controller.EditedAppointmentCopy.End = clientEnd;
        }
        if (tbSubject != null)
        {
            Controller.Subject = tbSubject.Text;
        }
        if (tbLocation != null)
        {
            Controller.Location = tbLocation.Text;
        }
        if (tbDescription != null)
        {
            Controller.Description = tbDescription.Text;
        }
        if (chkAllDay != null)
        {
            Controller.AllDay = chkAllDay.Checked;
        }
        if (edtShowTimeAs != null)
        {
            Controller.StatusId = Convert.ToInt32(edtShowTimeAs.Value);
        }
        if (edtLabel != null)
        {
            Controller.LabelId = Convert.ToInt32(edtLabel.Value);
        }
        if (chkReminder.Checked)
        {
            TimeSpan reminderTime = TimeSpan.Parse((string)cbReminder.Value);
            Controller.HasReminder             = true;
            Controller.ReminderTimeBeforeStart = reminderTime;
        }
        Controller.ResourceIds.Clear();
        foreach (RepeaterItem ri in rpResources.Items)
        {
            ASPxCheckBox chkResource = ri.FindControl("chkResource") as ASPxCheckBox;
            if (chkResource.Checked == true)
            {
                ASPxHiddenField field            = ri.FindControl("hfResource") as ASPxHiddenField;
                object          resourceIdObject = null;
                bool            success          = field.TryGet("resourceId", out resourceIdObject);
                if (!success)
                {
                    continue;
                }
                string resourceIdString = resourceIdObject.ToString();
                int    resourceId       = int.Parse(resourceIdString);
                Controller.ResourceIds.Add(resourceId);
            }
        }
        AssignControllerRecurrenceValues(clientStart);
    }
    }//end update

    /// <summary>
    /// we don't actually need an insert sub as shipment/vessel data is part of the ordertable which must have
    /// been saved before we get to shipment/vessel
    /// </summary>
    protected void insert_shipment()
    {
        try
        {
            //use order id 303635 for testing purposes
            int _orderid = wwi_func.vint(wwi_security.DecryptString(get_token("pid"), "publiship"));

            if (_orderid > 0)
            {
                OrderTable _t = new OrderTable(_orderid);

                //dlls
                //dlls
                int?         _intnull = null;
                ASPxComboBox _cb      = (ASPxComboBox)this.fmvShipment.FindControl("dxcboVesselID");
                if (_cb != null)
                {
                    _t.VesselID = _cb.Value != null?wwi_func.vint(_cb.Value.ToString()) : _intnull;
                }

                _cb = (ASPxComboBox)this.fmvShipment.FindControl("dxcboPackageTypeID");
                if (_cb != null)
                {
                    _t.PackageTypeID = _cb.Value != null?wwi_func.vint(_cb.Value.ToString()) : _intnull;
                }


                //why are the LCL/FCL values set to lcl=1, fcl=2 when the db data type is a bit? this doesn't make any sense
                //disbable code until confirmation from dave
                //_cb = (ASPxComboBox)this.fmvShipment.FindControl("dxcboFCLLCL");
                //if (_cb != null && _cb.Value != null) {
                //    string _lclfcl = _cb.Value.ToString();
                //    _t.Fcllcl = _lclfcl == "-1" ? true : false : false; //0 or -1
                //}

                ASPxTextBox _tx = (ASPxTextBox)this.fmvShipment.FindControl("dxtxtEstPallets");
                if (_tx != null && _tx.Text != "")
                {
                    _t.EstPallets = wwi_func.vint(_tx.Text.ToString());
                }

                _tx = (ASPxTextBox)this.fmvShipment.FindControl("dxtxtEstCartons");
                if (_tx != null && _tx.Text != "")
                {
                    _t.EstCartons = wwi_func.vint(_tx.Text.ToString());
                }

                _tx = (ASPxTextBox)this.fmvShipment.FindControl("dxtxtEstWeight");
                if (_tx != null && _tx.Text != "")
                {
                    _t.EstWeight = wwi_func.vint(_tx.Text.ToString());
                }

                _tx = (ASPxTextBox)this.fmvShipment.FindControl("dxtxtEstVolume");
                if (_tx != null && _tx.Text != "")
                {
                    _t.EstVolume = wwi_func.vfloat(_tx.Text.ToString());
                }

                _tx = (ASPxTextBox)this.fmvShipment.FindControl("dxtxtEstLCLWt");
                if (_tx != null && _tx.Text != "")
                {
                    _t.EstLCLWt = wwi_func.vint(_tx.Text.ToString());
                }

                _tx = (ASPxTextBox)this.fmvShipment.FindControl("dxtxtEstLCLVol");
                if (_tx != null && _tx.Text != "")
                {
                    _t.EstLCLVol = wwi_func.vfloat(_tx.Text.ToString());
                }

                _tx = (ASPxTextBox)this.fmvShipment.FindControl("dxtxtEst20");
                if (_tx != null && _tx.Text != "")
                {
                    _t.Est20 = wwi_func.vint(_tx.Text.ToString());
                }

                _tx = (ASPxTextBox)this.fmvShipment.FindControl("dxtxtEst40");
                if (_tx != null && _tx.Text != "")
                {
                    _t.Est40 = wwi_func.vint(_tx.Text.ToString());
                }

                //actuals
                _tx = (ASPxTextBox)this.fmvShipment.FindControl("dxtxtActualWeight");
                if (_tx != null && _tx.Text != "")
                {
                    _t.ActualWeight = wwi_func.vint(_tx.Text.ToString());
                }

                _tx = (ASPxTextBox)this.fmvShipment.FindControl("dxtxtActualVolume");
                if (_tx != null && _tx.Text != "")
                {
                    _t.ActualVolume = wwi_func.vfloat(_tx.Text.ToString());
                }

                _tx = (ASPxTextBox)this.fmvShipment.FindControl("dxtxtLCLWt");
                if (_tx != null && _tx.Text != "")
                {
                    _t.LCLWt = wwi_func.vint(_tx.Text.ToString());
                }

                _tx = (ASPxTextBox)this.fmvShipment.FindControl("dxtxtLCLvol");
                if (_tx != null && _tx.Text != "")
                {
                    _t.LCLVol = wwi_func.vfloat(_tx.Text.ToString());
                }

                _tx = (ASPxTextBox)this.fmvShipment.FindControl("dxtxtActual20");
                if (_tx != null && _tx.Text != "")
                {
                    _t.No20 = wwi_func.vint(_tx.Text.ToString());
                }

                _tx = (ASPxTextBox)this.fmvShipment.FindControl("dxtxtActual40");
                if (_tx != null && _tx.Text != "")
                {
                    _t.No40 = wwi_func.vint(_tx.Text.ToString());
                }

                //other
                _tx = (ASPxTextBox)this.fmvShipment.FindControl("dxtxtNumberOfPackages");
                if (_tx != null && _tx.Text != "")
                {
                    _t.NumberOfPackages = wwi_func.vint(_tx.Text.ToString());
                }

                _tx = (ASPxTextBox)this.fmvShipment.FindControl("dxtxtHouseBLNUmber");
                if (_tx != null && _tx.Text != "")
                {
                    _t.HouseBLNUmber = _tx.Text.ToString();
                }

                _tx = (ASPxTextBox)this.fmvShipment.FindControl("dxtxtJackets");
                if (_tx != null && _tx.Text != "")
                {
                    _t.Jackets = wwi_func.vint(_tx.Text.ToString());
                }

                _tx = (ASPxTextBox)this.fmvShipment.FindControl("dxtxtConsolNumber");
                if (_tx != null && _tx.Text != "")
                {
                    _t.ConsolNumber = wwi_func.vint(_tx.Text.ToString());
                }

                _tx = (ASPxTextBox)this.fmvShipment.FindControl("dxtxtConsolNumber");
                if (_tx != null && _tx.Text != "")
                {
                    _t.HodderPricePerCopy = wwi_func.vfloat(_tx.Text.ToString());
                }

                _tx = (ASPxTextBox)this.fmvShipment.FindControl("dxtxtHCCompositeRef");
                if (_tx != null && _tx.Text != "")
                {
                    _t.HCCompositeRef = _tx.Text.ToString();
                }

                _tx = (ASPxTextBox)this.fmvShipment.FindControl("dxtxtHCInvoiceAmount2");
                if (_tx != null && _tx.Text != "")
                {
                    _t.HCInvoiceAmount = wwi_func.vdecimal(_tx.Text.ToString());
                }

                _tx = (ASPxTextBox)this.fmvShipment.FindControl("dxtxtInsuranceValue");
                if (_tx != null && _tx.Text != "")
                {
                    _t.InsuranceValue = wwi_func.vdecimal(_tx.Text.ToString());
                }

                _tx = (ASPxTextBox)this.fmvShipment.FindControl("dxtxtImpression");
                if (_tx != null && _tx.Text != "")
                {
                    _t.Impression = _tx.Text.ToString();
                }

                //datetimes
                DateTime?    _dtnull = null; //default for nullable datetimes
                ASPxDateEdit _dt     = (ASPxDateEdit)this.fmvShipment.FindControl("dxdtETS");
                if (_dt != null)
                {
                    _t.Ets = _dt.Value != null?wwi_func.vdatetime(_dt.Date.ToString()) : _dtnull;
                }

                _dt = (ASPxDateEdit)this.fmvShipment.FindControl("dxdtETA");
                if (_dt != null)
                {
                    _t.Eta = _dt.Value != null?wwi_func.vdatetime(_dt.Date.ToString()) : _dtnull;
                }

                _dt = (ASPxDateEdit)this.fmvShipment.FindControl("dxdtJobClosureDate");
                if (_dt != null)
                {
                    _t.JobClosureDate = _dt.Value != null?wwi_func.vdatetime(_dt.Date.ToString()) : _dtnull;
                }

                _dt = (ASPxDateEdit)this.fmvShipment.FindControl("dxdtWarehouseDate");
                if (_dt != null)
                {
                    _t.WarehouseDate = _dt.Value != null?wwi_func.vdatetime(_dt.Date.ToString()) : _dtnull;
                }

                //checkboxes
                ASPxCheckBox _ck = (ASPxCheckBox)this.fmvShipment.FindControl("dxckJobClosed");
                if (_ck != null)
                {
                    _t.JobClosed = _ck.Checked;
                }

                _ck = (ASPxCheckBox)this.fmvShipment.FindControl("dxckOnBoard");
                if (_ck != null)
                {
                    _t.ShippedOnBoard = _ck.Checked;
                }

                //update record
                _t.Save();
            }
        }
        catch (Exception ex)
        {
            string _orderno = wwi_security.DecryptString(get_token("pno"), "publiship");
            string _ex      = ex.Message.ToString();
            this.dxlblErr.Text          = string.Format("Order # {0} NOT updated. Error: {1}", _orderno, _ex);
            this.dxpnlErr.ClientVisible = true;
        }
    }//end insert
        protected void Combo_Load(object sender, EventArgs e)
        {
            ASPxComboBox s = sender as ASPxComboBox;

            s.Value = dg.SettingsPager.PageSize;
        }
Beispiel #32
0
    /// <summary>
    /// update event for ETS grid
    /// check DATE. if it's been changed will need to update order table
    /// ordertable.ETS = new ETS, ordertable.VesselLastUpdated = now where ordertable.PortID = OriginPortID and ordertable.VesselID = VesselID
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void dxgrdETS_RowUpdating(object sender, DevExpress.Web.Data.ASPxDataUpdatingEventArgs e)
    {
        ASPxGridView _grd = (ASPxGridView)sender;

        int _voyageid = this.dxhfOrder.Contains("voyage") ? wwi_func.vint(this.dxhfOrder.Get("voyage").ToString()) : 0;
        int _vesselid = this.dxhfOrder.Contains("vessel") ? wwi_func.vint(this.dxhfOrder.Get("vessel").ToString()) : 0;
        //key for this record
        int _etsid = e.Keys["VoyageETSSubID"] != null?wwi_func.vint(e.Keys["VoyageETSSubID"].ToString()) : 0;

        //other required data
        int _portid = e.NewValues["OriginPortID"] != null?wwi_func.vint(e.NewValues["OriginPortID"].ToString()) : 0;

        DateTime?_dtets = e.NewValues["ETS"] != null?wwi_func.vdatetime(e.NewValues["ETS"].ToString()) : (DateTime?)null;

        ASPxComboBox _cbo = (ASPxComboBox)this.fmvVoyage.FindControl("dxcboVesselID");

        if (_cbo != null && _cbo.Value != null)
        {
            _vesselid = wwi_func.vint(_cbo.Value.ToString());
        }

        if (_etsid > 0)
        {
            VoyageETSSubTable _tbl = new VoyageETSSubTable(_etsid);
            _tbl.OriginPortID = _portid;
            _tbl.Ets          = _dtets;
            _tbl.Save();

            //***** for testing
            //_portid = 1;
            //_vesselid = 3246;
            //*****

            //update ordertable if _portid > 0 and _vesselid > 0
            //use voayge id NOT vessel id
            //if (_portid > 0 && _vesselid > 0) //&& (e.NewValues["ETS"] != e.OldValues["ETS"]))
            if (_portid > 0 && _voyageid > 0)
            {
                //update_ordertable_ets(_portid, _vesselid, _dtets);
                update_ordertable_ets(_portid, _voyageid, _dtets);

                //also does not work!
                //string[] _cols = { "OrderID", "ETS", "VesselLastUpdated" };
                //SqlQuery _qry = new Select(_cols).From(DAL.Logistics.Tables.OrderTable).
                //    Where(OrderTable.PortIDColumn).IsEqualTo(_portid).And(OrderTable.VesselIDColumn).IsEqualTo(_vesselid);
                //DataTable _dt = new DataTable();
                //DataColumn[] _col = { _dt.Columns["OrderID"] }; //need to define a primary key for update to work
                //_dt.PrimaryKey = _col;
                //
                //SqlDataAdapter _da = new SqlDataAdapter();
                //SqlCommandBuilder _cb = new SqlCommandBuilder(_da);
                //ConnectionStringSettings _cs = ConfigurationManager.ConnectionStrings["PublishipSQLConnectionString"];
                //using (SqlConnection _con = new SqlConnection(_cs.ConnectionString))
                //using (SqlCommand _cmd = new SqlCommand())
                //{
                //_cmd.CommandText = "SELECT OrderID, ETS, VesselLastUpdated FROM OrderTable WHERE ((PortID=@idport) AND (VesselID=@idvessel));";
                //_cmd.Parameters.AddWithValue("@idport", _portid);
                //_cmd.Parameters.AddWithValue("@idvessel", _vesselid);
                //_cmd.Connection = _con;
                //_da.SelectCommand = _cmd;
                //_da.Fill(_dt);

                //for (int _ix = 0; _ix < _dt.Rows.Count; _ix++)
                //{
                //    _dt.Rows[_ix]["ETS"] = Convert.ToDateTime(_dtets);
                //    _dt.Rows[_ix]["VesselLastUpdated"] = Convert.ToDateTime(_now);
                //}
                //
                //int _result = _da.Update(_dt);
                //}

                //does not work
                //string _sql = "UPDATE OrderTable " +
                //                    "SET OrderTable.Ets=@etsdate, " +
                //                    "OrderTable.VesselLastUpdated=@now " +
                //                    "FROM OrderTable as o " +
                //                    "WHERE o.OrderID IN (SELECT DISTINCT OrderID FROM OrderTable WHERE ((o.PortID=@port) AND (o.VesselID=@vessel)));";
                //ConnectionStringSettings _cs = ConfigurationManager.ConnectionStrings["PublishipSQLConnectionString"];
                //using (SqlConnection _con = new SqlConnection(_cs.ConnectionString))
                //using (SqlCommand _cmd = new SqlCommand())
                //{
                //    _cmd.CommandText = _sql;
                //    _cmd.Parameters.AddWithValue("@etsdate", Convert.ToDateTime(_dtets));
                //   _cmd.Parameters.AddWithValue("@now", Convert.ToDateTime(_now));
                //   _cmd.Parameters.AddWithValue("@port", _portid);
                //    _cmd.Parameters.AddWithValue("@vessel", _vesselid);
                //   _cmd.Connection = _con;
                //    _con.Open();
                //    int _result = _cmd.ExecuteNonQuery();
                //}

                //does not work
                //string[] _cols = { "OrderID" };
                //SqlQuery _qry = new Select(_cols).From(DAL.Logistics.Tables.OrderTable).
                //    Where(OrderTable.PortIDColumn).IsEqualTo(_portid).And(OrderTable.VesselIDColumn).IsEqualTo(_vesselid);
                //
                //IList<int> _orders = _qry.ExecuteTypedList<int>();
                //if (_orders.Count > 0)
                //{
                //    SubSonic.Update _upd = new SubSonic.Update(DAL.Logistics.Schemas.OrderTable);
                //    IList<int> _recordsaffected = _upd.Set(OrderTable.EtsColumn).EqualTo(Convert.ToDateTime(_dtets)).
                //                            Set(OrderTable.VesselLastUpdatedColumn).EqualTo(Convert.ToDateTime(_now)).
                //                            Where(OrderTable.OrderIDColumn).In(_orders).ExecuteTypedList<int>();
                //}
            }
            //end if vesselid > 0
        }//end if voyageetssubid > 0

        //MUST call this after insert or error: Specified method is not supported
        e.Cancel = true;
        _grd.CancelEdit();
        //rebind
        bind_ets_grid(_voyageid);
    }
    protected void update_charges()
    {
        try
        {
            int _orderid = wwi_func.vint(wwi_security.DecryptString(get_token("pid"), "publiship"));
            //Int32 _orderid = this.dxhfOrder.Contains("pid") ? wwi_func.vint(this.dxhfOrder.Get("pid").ToString()) : 0;
            if (_orderid > 0)
            {
                OrderTable _ot = new OrderTable(_orderid);

                ASPxComboBox _cbo = (ASPxComboBox)this.fmvCharge.FindControl("dxcboClientsTerms");
                if (_cbo != null)
                {
                    _ot.ClientsTerms = _cbo.Text.ToString();
                }

                _cbo = (ASPxComboBox)this.fmvCharge.FindControl("dxcboOriginTrucking");
                if (_cbo != null)
                {
                    _ot.OriginTrucking = _cbo.Text.ToString();
                }

                _cbo = (ASPxComboBox)this.fmvCharge.FindControl("dxcboOrignTHC");
                if (_cbo != null)
                {
                    _ot.OrignTHC = _cbo.Text.ToString();
                }

                _cbo = (ASPxComboBox)this.fmvCharge.FindControl("dxcboOriginDocs");
                if (_cbo != null)
                {
                    _ot.OriginDocs = _cbo.Text.ToString();
                }

                _cbo = (ASPxComboBox)this.fmvCharge.FindControl("dxcboFreight");
                if (_cbo != null)
                {
                    _ot.Freight = _cbo.Text.ToString();
                }

                _cbo = (ASPxComboBox)this.fmvCharge.FindControl("dxcboDestTHC");
                if (_cbo != null)
                {
                    _ot.DestTHC = _cbo.Text.ToString();
                }

                _cbo = (ASPxComboBox)this.fmvCharge.FindControl("dxcboDestPalletisation");
                if (_cbo != null)
                {
                    _ot.DestPalletisation = _cbo.Text.ToString();
                }

                _cbo = (ASPxComboBox)this.fmvCharge.FindControl("dxcboCustomsClearance");
                if (_cbo != null)
                {
                    _ot.CustomsClearance = _cbo.Text.ToString();
                }

                _cbo = (ASPxComboBox)this.fmvCharge.FindControl("dxcboDeliveryCharges");
                if (_cbo != null)
                {
                    _ot.DeliveryCharges = _cbo.Text.ToString();
                }

                ASPxMemo _mem = (ASPxMemo)this.fmvCharge.FindControl("dxmemCoLoaderComments");
                if (_mem != null)
                {
                    _ot.CoLoaderComments = _mem.Text.ToString();
                }

                _ot.Save();
                //confirm saved
                //string _msg = "Order " + this.dxlblOrderNo.Text.ToString() + " has been updated";
                //this.dxlblInfo.Text = _msg;
                //this.dxpnlMsg.ClientVisible = true;
            }
            else
            {
                string _err = "Unable to update charges. Order number not found.";
                this.dxlblErr.Text          = _err;
                this.dxpnlErr.ClientVisible = true;
            }
        }
        catch (Exception ex)
        {
            string _err = ex.Message.ToString();
            this.dxlblErr.Text          = _err;
            this.dxpnlErr.ClientVisible = true;
        }
    }
    protected void gvENT_OnRowUpdating(object sender, ASPxDataUpdatingEventArgs e)
    {
        ASPxGridView gv = (ASPxGridView)sender;

        //Get and Process the list of selected records in order to populate the list of pkvals
        #region process selected records
        var selected_keys = gvENT.GetSelectedFieldValues("subjID");


        ASPxCheckBox chkAllSelected    = gv.FindEditFormLayoutItemTemplateControl("chkUpdateAllSelected") as ASPxCheckBox;
        bool         updateALLSelected = chkAllSelected.Checked;


        List <int> pkvals = new List <int>();

        foreach (object key in e.Keys.Values)
        {
            int  ikey;
            bool isint = int.TryParse(key.ToString(), out ikey);
            if (isint)
            {
                pkvals.Add(ikey);
            }
        }

        //Add the other selected rows to the update if the user has selected the "Update All" checkbox
        if (selected_keys.Count > 0 && updateALLSelected)
        {
            foreach (object k in selected_keys)
            {
                int  ikey;
                bool isint = int.TryParse(k.ToString(), out ikey);
                if (!pkvals.Contains(ikey))
                {
                    pkvals.Add(ikey);
                }
            }
        }
        #endregion


        //Custom: retrieve specific data from the grid
        //Get the data from the ComboBoxes
        ASPxComboBox cboSS = (ASPxComboBox)gvENT.FindEditFormLayoutItemTemplateControl("cboSS");
        e.NewValues["ssID"] = cboSS.Value;

        ASPxComboBox cboSSD = (ASPxComboBox)gvENT.FindEditFormLayoutItemTemplateControl("cboSSD");
        e.NewValues["ssdID"] = cboSSD.Value;

        ASPxMemo notes = (ASPxMemo)gvENT.FindEditFormLayoutItemTemplateControl("notesEditor");
        e.NewValues["Notes"] = notes.Value;


        string result = dataops.dxGrid_UpdateData("subjID", pkvals, e.NewValues, "backend", "dbo", "tblSubject");
        gvENTstatus.Text = result;

        gv.CancelEdit();
        e.Cancel = true;
        ViewState["needBind"] = "true";
        gvENT.DataBind();
    }
Beispiel #35
0
        protected void treelstToolUnits_NodeValidating(object sender, TreeListNodeValidationEventArgs e)
        {
            #region Init some objest
            ASPxTreeList treelst     = sender as ASPxTreeList;
            ASPxComboBox cboCodeUnit = treelstToolUnits.FindEditCellTemplateControl(treelstToolUnits.Columns["Code"]
                                                                                    as TreeListDataColumn, "cboCodeUnit") as ASPxComboBox;
            TreeListEditCellTemplateContainer templateContainer = (TreeListEditCellTemplateContainer)cboCodeUnit.NamingContainer;
            string selectedCode = cboCodeUnit.SelectedItem != null?cboCodeUnit.SelectedItem.Value.ToString() : selectedCode = null;

            //List<ViewToolUnitConstruction> table = ToolUnitConstruction.ToList<ViewToolUnitConstruction>();
            //if (table == null)
            //    table = new List<ViewToolUnitConstruction>();
            #endregion

            #region Check Require NumberRequired
            //if (treelst.NewNodeParentKey != null)
            //{
            //    //if (this.toolBOL.isToolToolUnitRootId(Guid.Parse(treelst.NewNodeParentKey)))
            //    //{
            //       // e.NodeError = String.Format("Không cho phép cập nhật đơn vị tính mặt định!");
            //        //return;
            //    //}
            //}
            //else if (treelst.EditingNodeKey != null)
            //{
            //    if (this.toolBOL.isToolToolUnitRootId(Guid.Parse(treelst.EditingNodeKey)))
            //    {
            //        //e.NodeError = String.Format("Không cho phép cập nhật đơn vị tính mặt định!");
            //        //return;
            //    }
            //}

            if (selectedCode == null || selectedCode == "")
            {
                e.NodeError = String.Format("Bắt buộc chọn đơn vị tính!");
                return;
            }
            #endregion

            #region Check Require NumberRequired
            if (e.NewValues["NumRequired"] == null)
            {
                e.NodeError = String.Format("Bắt buộc nhập số lượng!");
                return;
            }
            #endregion

            #region Check Exist ToolUnitCode ---- Mode Edit Node
            if (templateContainer.NodeKey != null)
            {
                TreeListNode node = templateContainer.TreeList.FindNodeByKeyValue(templateContainer.NodeKey);
                // ViewToolUnitConstruction dataItem = (ViewToolUnitConstruction)node.DataItem;
                //string oldCode = dataItem.Code;
                //Check Exist Code before
                //if (table.Count > 0 && treelst.IsEditing && selectedCode != oldCode)
                //{
                //    if (table.Find(items => items.Code == selectedCode) != null)
                //    {
                //        e.NodeError = String.Format("Đơn vị tính {0} đã được chọn! Vui lòng chọn cái khác", selectedCode);
                //    }
                //}
            }
            #endregion

            #region Check Exist ToolUnitCode ---- Mode Add Node
            //else
            //{
            //if (table.Count > 0 && treelst.IsEditing)
            //{
            //    if (table.Find(items => items.Code == selectedCode) != null)
            //    {
            //        e.NodeError = String.Format("Đơn vị tính {0} đã được chọn! Vui lòng chọn cái khác", selectedCode);
            //    }
            //}
            //}
            #endregion
        }
Beispiel #36
0
    //end update

    /// <summary>
    /// new record
    /// </summary>
    protected int insert_contact()
    {
        int _newid = 0;
        //original value for countryname
        string _oldvalue = this.dxhfOrder.Contains("oldvalue") ? this.dxhfOrder.Get("oldvalue").ToString() : "";

        try
        {
            int?_intnull = null;
            //new instance of record
            EmployeesTable _tbl = new EmployeesTable();

            //get values off insert form
            //check duplicate name
            ASPxTextBox _txt = (ASPxTextBox)this.fmvEmployee.FindControl("dxtxtEmployeeInsert");
            if (_txt != null && _txt.Text != "")
            {
                string _newvalue  = _txt.Text.Trim().ToString(); //country name
                bool   _duplicate = _newvalue != _oldvalue?wwi_func.value_exists("Name", "EmployeesTable", _newvalue) : false;

                if (!_duplicate)
                {
                    //name
                    _tbl.Name = _txt.Text.ToString();
                    //email
                    _txt = (ASPxTextBox)this.fmvEmployee.FindControl("dxtxtEmailInsert");
                    if (_txt != null)
                    {
                        _tbl.EmailAddress = _txt.Text.ToString();
                    }
                    //office
                    ASPxComboBox _cbo = (ASPxComboBox)this.fmvEmployee.FindControl("dxcboOfficeID");
                    if (_cbo != null)
                    {
                        _tbl.OfficeID = _cbo.Value != null?wwi_func.vint(_cbo.Value.ToString()) : _intnull;
                    }
                    //department
                    _cbo = (ASPxComboBox)this.fmvEmployee.FindControl("dxcboDepartmentID");
                    if (_cbo != null)
                    {
                        _tbl.DepartmentID = _cbo.Value != null?wwi_func.vint(_cbo.Value.ToString()) : _intnull;
                    }
                    //live
                    ASPxCheckBox _ck = (ASPxCheckBox)this.fmvEmployee.FindControl("dxckLiveInsert");
                    if (_ck != null)
                    {
                        _tbl.Live = _ck.Checked;
                    }

                    _tbl.Save();
                    //get new id
                    _newid = (int)_tbl.GetPrimaryKeyValue();
                }//end if
                else
                {
                    string _ex = string.Format("{0} is already in database. This record will not be saved", _newvalue);
                    this.dxlblErr.Text          = _ex;
                    this.dxpnlErr.ClientVisible = true;
                } //end if duplicate
            }     //end if text
        }
        catch (Exception ex)
        {
            string _ex = ex.Message.ToString();
            this.dxlblErr.Text          = _ex;
            this.dxpnlErr.ClientVisible = true;
        }

        return(_newid);
    }
Beispiel #37
0
 protected void FillSectionCombo(ASPxComboBox cmb, string country)
 {
     if (string.IsNullOrEmpty(country)) return;
     SectionObjectDS.SelectParameters[0].DefaultValue = country;
     cmb.DataBind();
 }
Beispiel #38
0
    public static void SetDDLChartType(ASPxComboBox ddl)
    {
        try
        {
            DataTable dt = new DataTable();
            dt.Columns.Add("ID");
            dt.Columns.Add("name");

            DataRow dr;
            dr = dt.NewRow();
            dr["id"] = "1";
            dr["name"] = "กราฟแท่ง";
            dt.Rows.Add(dr);

            dr = dt.NewRow();
            dr["id"] = "2";
            dr["name"] = "กราฟเส้น";
            dt.Rows.Add(dr);

            dr = dt.NewRow();
            dr["id"] = "3";
            dr["name"] = "กราฟวงกลม";
            dt.Rows.Add(dr);

            if (dt.Rows.Count > 0)
            {
                ddl.ValueField = "ID";
                ddl.TextField = "name";

                ddl.DataSource = dt;
                ddl.DataBind();

                ddl.SelectedIndex = 0;
            }
        }
        catch (Exception ex)
        {

        }
    }
Beispiel #39
0
    protected void SaveJob()
    {
        try
        {
            ASPxGridView g = this.grid_Transport;


            ASPxTextBox houseId = g.FindEditFormTemplateControl("txt_Id") as ASPxTextBox;
            int         Id      = SafeValue.SafeInt(houseId.Text, 0);
            ASPxTextBox docNo   = g.FindEditFormTemplateControl("txt_DocNo") as ASPxTextBox;
            Wilson.ORMapper.OPathQuery query = new Wilson.ORMapper.OPathQuery(typeof(ContAsset), "Id='" + Id + "'");
            ContAsset contA = C2.Manager.ORManager.GetObject(query) as ContAsset;
            bool      isNew = false;
            if (Id == 0)
            {
                isNew         = true;
                contA         = new ContAsset();
                contA.DocNo   = C2Setup.GetNextNo("StoringOrder");
                contA.DocType = "SO";
            }
            ASPxTextBox jobNo = g.FindEditFormTemplateControl("txt_JobNo") as ASPxTextBox;
            contA.JobNo = jobNo.Text;
            ASPxComboBox depotCode = g.FindEditFormTemplateControl("cmb_DepotCode") as ASPxComboBox;
            contA.DepotCode = depotCode.Text;
            ASPxTextBox shipVessel = g.FindEditFormTemplateControl("txt_ShipVessel") as ASPxTextBox;
            contA.ShipVessel = shipVessel.Text;
            ASPxTextBox shipVoyage = g.FindEditFormTemplateControl("txt_ShipVoyage") as ASPxTextBox;
            contA.ShipVoyage = shipVoyage.Text;
            ASPxDateEdit shipEta = g.FindEditFormTemplateControl("date_ShipEta") as ASPxDateEdit;
            contA.ShipEta = shipEta.Date;
            ASPxDateEdit shipEtd = g.FindEditFormTemplateControl("date_ShipEtd") as ASPxDateEdit;
            contA.ShipEtd = shipEtd.Date;
            ASPxButtonEdit shipPol = g.FindEditFormTemplateControl("btn_ShipPol") as ASPxButtonEdit;
            contA.ShipPol = shipPol.Text;
            ASPxButtonEdit shipPod = g.FindEditFormTemplateControl("btn_ShipPod") as ASPxButtonEdit;
            contA.ShipPod = shipPod.Text;
            ASPxMemo shipNote = g.FindEditFormTemplateControl("txt_ShipNote") as ASPxMemo;
            contA.ShipNote = shipNote.Text;
            ASPxButtonEdit shipCarrierCode = g.FindEditFormTemplateControl("btn_ShipCarrierCode") as ASPxButtonEdit;
            contA.ShipCarrierCode = shipCarrierCode.Text;
            ASPxTextBox shipCarrierRef = g.FindEditFormTemplateControl("txt_ShipCarrierRef") as ASPxTextBox;
            contA.ShipCarrierRef = shipCarrierRef.Text;
            ASPxTextBox demurrageRef = g.FindEditFormTemplateControl("txt_DemurrageRef") as ASPxTextBox;
            contA.DemurrageRef = demurrageRef.Text;
            ASPxSpinEdit demurrageFreeDay = g.FindEditFormTemplateControl("spin_DemurrageFreeDay") as ASPxSpinEdit;
            contA.DemurrageFreeDay = SafeValue.SafeInt(demurrageFreeDay.Text, 0);
            ASPxDateEdit demurrageStartDate = g.FindEditFormTemplateControl("date_DemurrageStartDate") as ASPxDateEdit;
            contA.DemurrageStartDate = demurrageStartDate.Date;
            ASPxTextBox detentionRef = g.FindEditFormTemplateControl("txt_DetentionRef") as ASPxTextBox;
            contA.DetentionRef = detentionRef.Text;
            ASPxSpinEdit detentionFreeDay = g.FindEditFormTemplateControl("spin_DetentionFreeDay") as ASPxSpinEdit;
            contA.DetentionFreeDay = SafeValue.SafeInt(detentionFreeDay.Text, 0);
            ASPxDateEdit detentionStartDate = g.FindEditFormTemplateControl("date_DetentionStartDate") as ASPxDateEdit;
            contA.DetentionStartDate = detentionStartDate.Date;
            ASPxComboBox returnType = g.FindEditFormTemplateControl("cmb_ReturnType") as ASPxComboBox;
            contA.ReturnType = returnType.Text;
            ASPxButtonEdit shipperCode = g.FindEditFormTemplateControl("btn_ShipperCode") as ASPxButtonEdit;
            contA.ShipperCode = shipperCode.Text;
            ASPxTextBox shipperName = g.FindEditFormTemplateControl("txt_ShipperName") as ASPxTextBox;
            contA.ShipperName = shipperName.Text;
            ASPxButtonEdit consigneeCode = g.FindEditFormTemplateControl("btn_ConsigneeCode") as ASPxButtonEdit;
            contA.ConsigneeCode = consigneeCode.Text;
            ASPxTextBox consigneeName = g.FindEditFormTemplateControl("txt_ConsigneeName") as ASPxTextBox;
            contA.ConsigneeName = consigneeName.Text;
            ASPxButtonEdit haulierCode = g.FindEditFormTemplateControl("btn_HaulierCode") as ASPxButtonEdit;
            contA.HaulierCode = haulierCode.Text;
            ASPxDateEdit haulierCompleteDate = g.FindEditFormTemplateControl("date_HaulierCompleteDate") as ASPxDateEdit;
            contA.HaulierCompleteDate = haulierCompleteDate.Date;
            ASPxTextBox instruction = g.FindEditFormTemplateControl("txt_Instruction") as ASPxTextBox;
            contA.Instruction = instruction.Text;


            if (isNew)
            {
                contA.CreateBy       = EzshipHelper.GetUserName();
                contA.CreateDateTime = DateTime.Now;
                C2.Manager.ORManager.StartTracking(contA, Wilson.ORMapper.InitialState.Inserted);
                C2.Manager.ORManager.PersistChanges(contA);

                C2Setup.SetNextNo("StoringOrder", contA.DocNo);
                houseId.Text = contA.Id.ToString();
                //this.txt_JobNo.Text = tpt1.JobNo;
                docNo.Text          = contA.DocNo;
                Session["ExpWhere"] = "Id='" + contA.Id + "'";
                this.dsTransport.FilterExpression = Session["ExpWhere"].ToString();
                if (this.grid_Transport.GetRow(0) != null)
                {
                    this.grid_Transport.StartEdit(0);
                }
            }
            else
            {
                contA.UpdateBy       = EzshipHelper.GetUserName();
                contA.UpdateDateTime = DateTime.Now;
                C2.Manager.ORManager.StartTracking(contA, Wilson.ORMapper.InitialState.Updated);
                C2.Manager.ORManager.PersistChanges(contA);
                string sql = "update cont_assetEvent set pod='" + shipPod.Text + "',pol='" + shipPol.Text + "' where docNo='" + docNo.Text + "' ";
                C2.Manager.ORManager.ExecuteCommand(sql);
            }
        }
        catch (Exception ex)
        { throw new Exception(ex.Message + ex.StackTrace); }
    }
        protected void grid_CellEditorInitialize(object sender, DevExpress.Web.ASPxGridViewEditorEventArgs e)
        {
            if (e.Column.FieldName == "Modulo")
            {
                ASPxComboBox cmb = e.Editor as ASPxComboBox;
                cmb.Items.Add("Comercial", "Comercial");
                cmb.Items.Add("Riesgo", "Riesgo");
                cmb.Items.Add("Fiscalia", "Fiscalia");
                cmb.Items.Add("Operaciones", "Operaciones");
                cmb.Items.Add("Contabilidad", "Contabilidad");
                cmb.Items.Add("Seguimiento", "Seguimiento");
                cmb.Items.Add("Posicion", "Posicion");
                cmb.Items.Add("Configuracion", "Configuracion");
                hdn_modulo["hdn_modulo"] = cmb.Text;
            }
            if (e.Column.FieldName == "Tipo Opcion")
            {
                var          auxItem = "";
                ASPxComboBox cmb     = e.Editor as ASPxComboBox;
                SqlCommand   command = new SqlCommand("sp_tipoOpciones", connection);
                command.CommandType = System.Data.CommandType.StoredProcedure;
                command.Parameters.AddWithValue("@modulo", hdn_modulo["hdn_modulo"]);
                if (connection.State != ConnectionState.Open)
                {
                    connection.Open();
                }
                SqlDataReader reader = command.ExecuteReader();
                while (reader.Read())
                {
                    if (reader["TipoOpcion"].ToString() != auxItem)
                    {
                        cmb.Items.Add(reader["TipoOpcion"].ToString(), reader["TipoOpcion"].ToString());
                    }
                    auxItem = reader["TipoOpcion"].ToString();
                }
                reader.Close();

                selTipoOpcion = cmb.Text;
            }
            if (e.Column.FieldName == "Opciones")
            {
                ASPxComboBox cmb     = e.Editor as ASPxComboBox;
                SqlCommand   command = new SqlCommand("sp_tipoOpciones", connection);
                command.CommandType = System.Data.CommandType.StoredProcedure;
                command.Parameters.AddWithValue("@modulo", hdn_modulo["hdn_modulo"]);
                if (connection.State != ConnectionState.Open)
                {
                    connection.Open();
                }
                SqlDataReader reader = command.ExecuteReader();
                while (reader.Read())
                {
                    //if (reader["TipoOpcion"].ToString() == selTipoOpcion)
                    cmb.Items.Add(reader["Opcion"].ToString().Trim(), reader["Opcion"].ToString());
                }
                reader.Close();
                selOpcion = cmb.Text;
            }
            if (e.Column.FieldName == "Permiso")
            {
                ASPxComboBox cmb     = e.Editor as ASPxComboBox;
                SqlCommand   command = new SqlCommand("sp_permisos", connection);
                command.CommandType = System.Data.CommandType.StoredProcedure;
                command.Parameters.AddWithValue("@modulo", hdn_modulo["hdn_modulo"]);
                command.Parameters.AddWithValue("@opcion", selOpcion);
                if (connection.State != ConnectionState.Open)
                {
                    connection.Open();
                }
                SqlDataReader reader = command.ExecuteReader();
                while (reader.Read())
                {
                    cmb.Items.Add(reader["Permiso"].ToString(), reader["Permiso"].ToString());
                }
                reader.Close();
            }
            if (e.Column.FieldName == "Perfil")
            {
                ASPxTextBox txt = e.Editor as ASPxTextBox;
                if (hdn_update["hdn_update"].ToString() == "1")
                {
                    if (txtPerfil.Value != "")
                    {
                        txt.Text = txtPerfil.Value;
                    }
                }
            }
        }
Beispiel #41
0
    /// <summary>
    /// 作者:Tony 2011-02-23
    /// 功能:设置ASPxComboBox的None显示值,一般在ASPxComboBox的DataBound事件中进行调用
    /// </summary>
    /// <param name="cb"></param>
    /// <param name="noneDisplayText"></param>
    protected void SetASPxComboBoxNullItem(ASPxComboBox cb, string noneDisplayText)
    {
        if (string.IsNullOrEmpty(noneDisplayText))
            noneDisplayText = "(none)";

        if (cb != null)
        {
            ListEditItem item = new ListEditItem("noneDisplayText", "");
            cb.Items.Insert(0, item);
            cb.SelectedItem = item;
        }
    }
Beispiel #42
0
    protected void AddOrUpdate()
    {
        try
        {
            ASPxPageControl pageControl = this.grid.FindEditFormTemplateControl("pageControl") as ASPxPageControl;
            ASPxTextBox     txt_Id      = this.grid.FindEditFormTemplateControl("txt_Id") as ASPxTextBox;
            ASPxTextBox     txt_Name    = grid.FindEditFormTemplateControl("txt_Name") as ASPxTextBox;
            ASPxTextBox     txtIcNo     = pageControl.FindControl("txtIcNo") as ASPxTextBox;
            string          Id          = SafeValue.SafeString(txt_Id.Text, "");
            string          name        = txt_Name.Text;
            //throw new Exception(name);
            Wilson.ORMapper.OPathQuery query = new Wilson.ORMapper.OPathQuery(typeof(HrPerson), "Id='" + Id + "'");
            HrPerson person = C2.Manager.ORManager.GetObject(query) as HrPerson;
            bool     action = false;

            if (SafeValue.SafeString(txt_Name.Text, "") == "")
            {
                throw new Exception("Name not be null!!!");
                return;
            }
            //if (SafeValue.SafeString(txtIcNo.Text,"") == "")
            //{
            //    throw new Exception("Ic No not be null!!!");
            //    return;
            //}
            string sql = string.Format(@"select count(*) from Hr_Person where IcNo='{0}' and Id<>{1}", SafeValue.SafeString(txtIcNo.Text, ""), SafeValue.SafeString(txt_Id.Text, "0"));
            //string sql=string.Format(@"select count(*) from Hr_Person where Id={0}",SafeValue.SafeString(txt_Id.Text,""),SafeValue.SafeString(txt_Name.Text,""));
            //throw new Exception(sql);
            int cnt = SafeValue.SafeInt(C2.Manager.ORManager.ExecuteScalar(sql), 0);
            if (cnt > 0)
            {
                throw new Exception("Please enter another value of the Ic No again!");
                return;
            }
            if (person == null || person.Id == 0)
            {
                action = true;
                person = new HrPerson();
            }
            //throw new Exception(name);
            person.Name = name;
            ASPxTextBox interviewId = this.grid.FindEditFormTemplateControl("txt_InterviewId") as ASPxTextBox;
            person.InterviewId = SafeValue.SafeString(interviewId.Text, "");
            ASPxTextBox recruitId = this.grid.FindEditFormTemplateControl("txt_RecruitId") as ASPxTextBox;
            person.RecruitId = SafeValue.SafeString(recruitId.Text, "");
            ASPxComboBox gender = pageControl.FindControl("cbo_Gender") as ASPxComboBox;
            person.Gender = gender.Text;
            ASPxTextBox icno = pageControl.FindControl("txtIcNo") as ASPxTextBox;
            person.IcNo = icno.Text;

            ASPxDateEdit birthday = pageControl.FindControl("date_Birthday") as ASPxDateEdit;
            person.BirthDay = birthday.Date;

            ASPxTextBox ss1 = pageControl.FindControl("txt_s1") as ASPxTextBox;
            person.Status1 = S.Text(ss1.Text);
            ASPxTextBox ss2 = pageControl.FindControl("txt_s2") as ASPxTextBox;
            person.Status2 = S.Text(ss2.Text);

            ASPxDateEdit dd1 = pageControl.FindControl("date_d1") as ASPxDateEdit;
            person.Date1 = S.Date(dd1.Date);
            ASPxDateEdit dd2 = pageControl.FindControl("date_d2") as ASPxDateEdit;
            person.Date2 = S.Date(dd2.Date);


            ASPxButtonEdit country = pageControl.FindControl("txt_Country") as ASPxButtonEdit;
            person.Country = country.Text;
            ASPxTextBox race = pageControl.FindControl("txt_Race") as ASPxTextBox;
            person.Race = race.Text;
            ASPxTextBox religion = pageControl.FindControl("txt_Religion") as ASPxTextBox;
            person.Religion = religion.Text;
            ASPxCheckBox married = pageControl.FindControl("ckb_Married") as ASPxCheckBox;
            if (married.Checked)
            {
                person.Married = "Y";
            }
            else
            {
                person.Married = "N";
            }
            ASPxTextBox telephone = pageControl.FindControl("txt_Telephone") as ASPxTextBox;
            person.Telephone = telephone.Text;
            ASPxTextBox email = pageControl.FindControl("txt_Email") as ASPxTextBox;
            person.Email = email.Text;
            ASPxComboBox hrGroup = pageControl.FindControl("cmb_HrGroup") as ASPxComboBox;
            person.HrGroup = hrGroup.Text;
            ASPxComboBox department = pageControl.FindControl("cmb_Department") as ASPxComboBox;
            person.Department = department.Text;
            ASPxComboBox hrRole = pageControl.FindControl("cmb_Role") as ASPxComboBox;
            person.HrRole = hrRole.Text;
            ASPxMemo address = pageControl.FindControl("memo_Address") as ASPxMemo;
            person.Address = address.Text;
            ASPxMemo remark = pageControl.FindControl("memo_Remark") as ASPxMemo;
            person.Remark = remark.Text;
            ASPxMemo remark1 = pageControl.FindControl("memo_Profile") as ASPxMemo;
            person.Remark1 = remark1.Text;
            ASPxMemo remark2 = pageControl.FindControl("memo_Work") as ASPxMemo;
            person.Remark2 = remark2.Text;
            ASPxMemo remark3 = pageControl.FindControl("memo_Education") as ASPxMemo;
            person.Remark3 = remark3.Text;
            ASPxMemo remark4 = pageControl.FindControl("memo_Family") as ASPxMemo;
            person.Remark4 = remark4.Text;
            ASPxMemo remark5 = pageControl.FindControl("memo_Emergency") as ASPxMemo;
            person.Remark5 = remark5.Text;
            ASPxSpinEdit spin_Amount1 = pageControl.FindControl("spin_Amount1") as ASPxSpinEdit;
            person.Amount1 = SafeValue.SafeDecimal(spin_Amount1.Value);
            ASPxSpinEdit spin_Amount2 = pageControl.FindControl("spin_Amount2") as ASPxSpinEdit;
            person.Amount2 = SafeValue.SafeDecimal(spin_Amount2.Value);
            ASPxSpinEdit spin_Amount3 = pageControl.FindControl("spin_Amount3") as ASPxSpinEdit;
            person.Amount3 = SafeValue.SafeDecimal(spin_Amount3.Value);
            //throw new Exception(person.Name);
            if (action)
            {
                person.Status         = txt_Status.Text;
                person.CreateBy       = HttpContext.Current.User.Identity.Name;
                person.CreateDateTime = DateTime.Now;
                Manager.ORManager.StartTracking(person, Wilson.ORMapper.InitialState.Inserted);
                Manager.ORManager.PersistChanges(person);
            }
            else
            {
                ASPxComboBox newStatus = grid.FindEditFormTemplateControl("cmb_Type") as ASPxComboBox;
                person.Status = newStatus.Text;
                string oldStatus = SafeValue.SafeString(C2.Manager.ORManager.ExecuteScalar(string.Format("select Status from Hr_Person where Id={0}", Id)));
                if (oldStatus != SafeValue.SafeString(newStatus.Text))
                {
                    this.grid.CancelEdit();
                }
                //this.Response.Write("<script>if(confirm('Confirm change this'+txt_Status.GetText()+' To'+cmb_Type.GetText()+'?')){alert('Sucess!');};</script>");
                person.UpdateBy       = HttpContext.Current.User.Identity.Name;
                person.UpdateDateTime = DateTime.Now;
                Manager.ORManager.StartTracking(person, Wilson.ORMapper.InitialState.Updated);
                Manager.ORManager.PersistChanges(person);
            }
            Session["PersonWhere" + txt_Status.Text] = "Id='" + person.Id + "' and Status='" + txt_Status.Text + "'";
            this.dsPerson.FilterExpression           = Session["PersonWhere" + txt_Status.Text].ToString();
            if (this.grid.GetRow(0) != null)
            {
                this.grid.StartEdit(0);
            }
            else
            {
                Session["PersonWhere" + txt_Status.Text] = "Id>0 and Status='" + txt_Status.Text + "'";
                this.dsPerson.FilterExpression           = Session["PersonWhere" + txt_Status.Text].ToString();
            }
        }
        catch (Exception ex) { throw new Exception(ex.Message + ex.StackTrace); }
    }
Beispiel #43
0
    public static void SetDDLBudgetYear(ASPxComboBox ddl)
    {
        try
        {
            DataTable dt = new DataTable();
            dt.Columns.Add("budget_year_value");
            dt.Columns.Add("budget_year_display");

            int startYear = DateTime.Now.AddYears(-10).Year;
            for (int i = startYear; i <= (DateTime.Now.Year + 1); i++)
            {
                DataRow dr = dt.NewRow();
                dr["budget_year_value"] = (i + 543).ToString();
                dr["budget_year_display"] = (i + 543).ToString();
                dt.Rows.Add(dr);
            }

            if (dt.Rows.Count > 0)
            {
                ddl.ValueField = "budget_year_value";
                ddl.TextField = "budget_year_display";

                ddl.DataSource = dt;
                ddl.DataBind();
                ddl.Value = setBudgetYear(DateTime.Now);
            }
        }
        catch (Exception ex)
        {

        }
    }
Beispiel #44
0
    private string job_save()
    {
        string res = "";

        try
        {
            ASPxPageControl            pageControl = this.grid_job.FindEditFormTemplateControl("pageControl") as ASPxPageControl;
            ASPxTextBox                txt_JobNo   = this.grid_job.FindEditFormTemplateControl("txt_JobNo") as ASPxTextBox;
            string                     jobNo       = SafeValue.SafeString(txt_JobNo.Text, "");
            Wilson.ORMapper.OPathQuery query       = new Wilson.ORMapper.OPathQuery(typeof(C2.CtmJob), "JobNo='" + jobNo + "'");
            C2.CtmJob                  ctmJob      = C2.Manager.ORManager.GetObject(query) as C2.CtmJob;

            ASPxDateEdit jobDate = this.grid_job.FindEditFormTemplateControl("txt_JobDate") as ASPxDateEdit;
            bool         isNew   = false;
            if (ctmJob == null)
            {
                isNew        = true;
                ctmJob       = new C2.CtmJob();
                ctmJob.JobNo = C2Setup.GetNextNo("", "CTM_Job", jobDate.Date);
            }
            ASPxComboBox   cbb_JobType     = this.grid_job.FindEditFormTemplateControl("cbb_JobType") as ASPxComboBox;
            ASPxButtonEdit btn_ClientId    = this.grid_job.FindEditFormTemplateControl("btn_ClientId") as ASPxButtonEdit;
            ASPxTextBox    txt_ClientRefNo = this.grid_job.FindEditFormTemplateControl("txt_ClientRefNo") as ASPxTextBox;

            ASPxTextBox txt_notifiEmail = this.grid_job.FindEditFormTemplateControl("txt_notifiEmail") as ASPxTextBox;

            ASPxButtonEdit btn_SubClientId   = this.grid_job.FindEditFormTemplateControl("btn_SubClientId") as ASPxButtonEdit;
            ASPxButtonEdit txt_WareHouseId   = this.grid_job.FindEditFormTemplateControl("txt_WareHouseId") as ASPxButtonEdit;
            ASPxTextBox    txt_ClientContact = this.grid_job.FindEditFormTemplateControl("txt_ClientContact") as ASPxTextBox;

            ctmJob.ClientContact = SafeValue.SafeString(txt_ClientContact.Text);
            ctmJob.JobDate       = SafeValue.SafeDate(jobDate.Date, new DateTime(1753, 1, 1));
            ctmJob.JobType       = cbb_JobType.Text;
            ctmJob.ClientId      = btn_ClientId.Text;
            ctmJob.ClientRefNo   = txt_ClientRefNo.Text;
            ctmJob.EmailAddress  = txt_notifiEmail.Text;
            ctmJob.SubClientId   = btn_SubClientId.Text;

            if (txt_WareHouseId != null)
            {
                ctmJob.WareHouseCode = txt_WareHouseId.Text;
            }
            string userId = HttpContext.Current.User.Identity.Name;
            if (isNew)
            {
                ctmJob.StatusCode = "USE";

                ctmJob.CreateBy       = userId;
                ctmJob.CreateDateTime = DateTime.Now;
                ctmJob.UpdateBy       = userId;
                ctmJob.UpdateDateTime = DateTime.Now;
                C2.Manager.ORManager.StartTracking(ctmJob, Wilson.ORMapper.InitialState.Inserted);
                C2.Manager.ORManager.PersistChanges(ctmJob);
            }
            else
            {
                ctmJob.UpdateBy       = userId;
                ctmJob.UpdateDateTime = DateTime.Now;
                C2.Manager.ORManager.StartTracking(ctmJob, Wilson.ORMapper.InitialState.Updated);
                C2.Manager.ORManager.PersistChanges(ctmJob);

                C2.CtmJobEventLog elog = new C2.CtmJobEventLog();
                elog.Platform_isWeb();
                elog.Controller = userId;
                elog.ActionLevel_isJOB(ctmJob.Id);
                elog.Remark = "Job Update";
                elog.log();
            }

            if (isNew)
            {
                txt_JobNo.Text = ctmJob.JobNo;
                //txt_search_JobNo.Text = txt_JobNo.Text;
                C2Setup.SetNextNo("", "CTM_Job", ctmJob.JobNo, jobDate.Date);
            }

            //res = Job_Check_JobLevel(ctmJob.JobNo);

            Session["CTM_Job_" + txt_search_JobNo.Text] = "JobNo='" + ctmJob.JobNo + "'";
            this.dsJob.FilterExpression = Session["CTM_Job_" + txt_search_JobNo.Text].ToString();
            if (this.grid_job.GetRow(0) != null)
            {
                this.grid_job.StartEdit(0);
            }
        }
        catch { }

        return(res);
    }
Beispiel #45
0
    public static void SetDDLJDEVALITEM(ASPxComboBox ddl, int TypeID)
    {
        try
        {
            string sql = "select * from SMM_JD_EVAL_ITEM where TYPE_ID=" + TypeID;
            SqlDataAdapter da = new SqlDataAdapter(sql, StaticDefaultConnectionString);
            DataTable dt = new DataTable();
            da.Fill(dt);

            if (dt.Rows.Count > 0)
            {
                ddl.ValueField = "ITEM_ID";
                ddl.TextField = "ITEM_NAME";

                ddl.DataSource = dt;
                ddl.DataBind();
            }
        }
        catch (Exception ex)
        {

        }
    }
Beispiel #46
0
        protected void ASPxGridView2_CellEditorInitialize(object sender, DevExpress.Web.ASPxGridView.ASPxGridViewEditorEventArgs e)
        {
            ASPxGridView aspx1 = sender as ASPxGridView;

            //aspx1.KeyFieldName = "LJDM1";
            if (ASPxGridView2.IsEditing)
            {
                string rowid1 = "";
                try
                {
                    rowid1 = (string)ASPxGridView2.GetRowValuesByKeyValue(e.KeyValue, "ROWID");
                }
                catch { }
                string LJDM1 = "";
                try
                {
                    LJDM1 = dc.GetValue("select ljdm1  from SJBOMSOTHMUTI where so='" + Request["so"].ToString() + "' and jhdm='" + Request["planCode"].ToString()
                                        + "' and rowid='" + rowid1 + "'   ");
                    //LJDM1 = (string)ASPxGridView2.GetRowValuesByKeyValue(e.KeyValue, "LJDM1");
                }
                catch { }
                if (e.Column.FieldName == "GWMC")
                {
                    ASPxComboBox combo = e.Editor as ASPxComboBox;
                    string       sql   = "select location_code from data_plan_standard_Bom where plan_code='" + Request["planCode"].ToString() + "' and item_code='" + LJDM1 + "' order by location_code";
                    DataTable    dt    = dc.GetTable(sql);
                    combo.Items.Clear();
                    for (int i = 0; i < dt.Rows.Count; i++)
                    {
                        combo.Items.Add(dt.Rows[i]["location_code"].ToString(), dt.Rows[i]["location_code"].ToString());
                    }
                }
                if (e.Column.FieldName == "GWMC1")
                {
                    ASPxComboBox combo = e.Editor as ASPxComboBox;
                    string       sql   = "select distinct location_code from data_plan_standard_Bom where plan_code='" + Request["planCode"].ToString() + "' order by location_code ";
                    DataTable    dt    = dc.GetTable(sql);
                    combo.Items.Clear();
                    for (int i = 0; i < dt.Rows.Count; i++)
                    {
                        combo.Items.Add(dt.Rows[i]["location_code"].ToString(), dt.Rows[i]["location_code"].ToString());
                    }
                }
                if (e.Column.FieldName == "GXMC1")
                {
                    ASPxComboBox combo = e.Editor as ASPxComboBox;
                    string       GWMC1 = "";
                    GWMC1 = dc.GetValue("select gwmc1  from SJBOMSOTHMUTI where so='" + Request["so"].ToString() + "' and jhdm='" + Request["planCode"].ToString()
                                        + "' and rowid='" + rowid1 + "'   ");
                    string sql = "select distinct process_code from data_plan_standard_Bom where plan_code='" + Request["planCode"].ToString() + "' and location_code='" + GWMC1 + "' order by process_code";
                    dc.setTheSql(sql);
                    DataTable dt = dc.GetTable();

                    combo.Items.Clear();
                    for (int i = 0; i < dt.Rows.Count; i++)
                    {
                        combo.Items.Add(dt.Rows[i]["process_code"].ToString(), dt.Rows[i]["process_code"].ToString());
                    }
                    combo.Callback += new CallbackEventHandlerBase(cmbGXMC1_OnCallback);
                }
            }
        }
Beispiel #47
0
    public static void SetDDLJDSUBGROP34(ASPxComboBox ddl,int GroupID)
    {
        try
        {
            string sql = "SELECT SUB_GROUP_ID,SUB_GROUP_NAME FROM SMM_JD_SUB_GROUP34 WHERE GROUP_ID="+ GroupID ;
            SqlDataAdapter da = new SqlDataAdapter(sql, StaticDefaultConnectionString);
            DataTable dt = new DataTable();
            da.Fill(dt);

            if (dt.Rows.Count > 0)
            {

                ddl.ValueField = "SUB_GROUP_ID";
                ddl.TextField = "SUB_GROUP_NAME";

                ddl.DataSource = dt;
                ddl.DataBind();
            }
        }
        catch (Exception ex)
        {

        }
    }
    protected void grid_CustomDataCallback(object sender, DevExpress.Web.ASPxGridView.ASPxGridViewCustomDataCallbackEventArgs e)
    {
        string paras = e.Parameters;

        string[] ar = paras.Split('_');

        //if (paras == "OK")
        //{
        //    #region
        //    e.Result = create_house(list.Count, -1);
        //    #endregion
        //}
        if (paras == "NewOne")
        {
            #region
            e.Result = create_house("one");
            #endregion
        }
        if (paras == "NewAll")
        {
            #region

            e.Result = create_house("all");
            #endregion
        }
        if (paras == "SaveAll")
        {
            #region
            if (list.Count > 0)
            {
                for (int i = 0; i < list.Count; i++)
                {
                    int      id           = list[i].id;
                    DateTime deliveryDate = list[i].deliveryDate;
                    object   qty          = (object)list[i].qty;
                    object   weight       = (object)list[i].weight;
                    object   volume       = (object)list[i].volume;
                    object   sendMode     = (object)list[i].sendMode;
                    e.Result = update_house(id, deliveryDate, qty, weight, volume, sendMode);
                }
            }
            else
            {
                e.Result = "Pls Select at least one";
            }
            #endregion
        }
        if (ar.Length >= 2)
        {
            if (ar[0].Equals("CargoListline"))
            {
                #region
                ASPxGridView grid = sender as ASPxGridView;

                int         rowIndex = SafeValue.SafeInt(ar[1], -1);
                ASPxTextBox txt_Id   = grid.FindRowCellTemplateControl(rowIndex, null, "txt_Id") as ASPxTextBox;
                e.Result = txt_Id.Text;
                #endregion
            }
            if (ar[0].Equals("Saveline"))
            {
                #region
                ASPxGridView grid = sender as ASPxGridView;

                int          rowIndex          = SafeValue.SafeInt(ar[1], -1);
                ASPxLabel    Id                = this.grid.FindRowCellTemplateControl(rowIndex, (DevExpress.Web.ASPxGridView.GridViewDataColumn) this.grid.Columns["Id"], "lbl_Id") as ASPxLabel;
                ASPxDateEdit date_DeliveryDate = this.grid.FindRowCellTemplateControl(rowIndex, (DevExpress.Web.ASPxGridView.GridViewDataColumn) this.grid.Columns["DeliveryDate"], "date_DeliveryDate") as ASPxDateEdit;
                ASPxComboBox cbb_SendMode      = this.grid.FindRowCellTemplateControl(rowIndex, (DevExpress.Web.ASPxGridView.GridViewDataColumn) this.grid.Columns["SendMode"], "cbb_SendMode") as ASPxComboBox;
                ASPxSpinEdit spin_Qty          = this.grid.FindRowCellTemplateControl(rowIndex, (DevExpress.Web.ASPxGridView.GridViewDataColumn) this.grid.Columns["QtyOrig"], "spin_Qty") as ASPxSpinEdit;
                ASPxSpinEdit spin_Weight       = this.grid.FindRowCellTemplateControl(rowIndex, (DevExpress.Web.ASPxGridView.GridViewDataColumn) this.grid.Columns["WeightOrig"], "spin_Weight") as ASPxSpinEdit;
                ASPxSpinEdit spin_Volume       = this.grid.FindRowCellTemplateControl(rowIndex, (DevExpress.Web.ASPxGridView.GridViewDataColumn) this.grid.Columns["VolumeOrig"], "spin_Volume") as ASPxSpinEdit;
                e.Result = update_house(SafeValue.SafeInt(Id.Text, 0), date_DeliveryDate.Date, spin_Qty.Value, spin_Weight.Value, spin_Volume.Value, cbb_SendMode.Value);
                #endregion
            }
        }
    }
Beispiel #49
0
    public static void SetDDLORGL3(ASPxComboBox ddl)
    {
        try
        {
            string sql = "SELECT ORG_SERIAL,ORG_NAME,ORG_ABBR FROM vw_SMM_ORG WHERE ORG_LEVEL IN(3) order by ORG_NAME";
            SqlDataAdapter da = new SqlDataAdapter(sql, StaticDefaultConnectionString);
            DataTable dt = new DataTable();
            da.Fill(dt);

            DataRow row;
            row = dt.NewRow();
            //row["ORG_SERIAL"] = "0";
            //row["ORG_NAME"] = "--ALL--";
            //row["ORG_ABBR"] = "";
            //dt.Rows.InsertAt(row, 0);

            if (dt.Rows.Count > 0)
            {
                ddl.Columns.Clear();
                ddl.Columns.Add("ORG_NAME", "ชื่อหน่วยงาน");
                //ddl.Columns.Add("ORG_ABBR", "ชื่อย่อ");

                ddl.ValueField = "ORG_SERIAL";
                ddl.TextField = "ORG_NAME";

                ddl.DataSource = dt;
                ddl.DataBind();
            }
        }
        catch (Exception ex)
        {

        }
    }
    protected void AddOrUpdate()
    {
        ASPxTextBox txt_pId = this.ASPxGridView1.FindEditFormTemplateControl("txt_Id") as ASPxTextBox;
        ASPxTextBox txtCode = ASPxGridView1.FindEditFormTemplateControl("txt_ProductCode") as ASPxTextBox;
        string      pId     = SafeValue.SafeString(txt_pId.Text, "");

        Wilson.ORMapper.OPathQuery query = new Wilson.ORMapper.OPathQuery(typeof(RefProduct), "Id='" + pId + "'");
        RefProduct product = C2.Manager.ORManager.GetObject(query) as RefProduct;
        bool       action  = false;
        string     code    = "";

        if (product == null)
        {
            action  = true;
            product = new RefProduct();
            string    sql = "select Code from ref_product";
            DataTable dt  = C2.Manager.ORManager.GetDataSet(sql).Tables[0];
            if (dt.Rows.Count > 0)
            {
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    code = dt.Rows[i]["Code"].ToString();
                    if (txtCode.Text.ToUpper() == code.ToUpper())
                    {
                        throw new Exception("Please enter another value of the Code again!");
                    }
                }
            }
        }
        if (txtCode.Text == "")
        {
            code = C2Setup.GetNextNo("", "Product", DateTime.Now);
        }
        else
        {
            code = txtCode.Text;
        }
        product.Code = code;
        ASPxTextBox txtName = ASPxGridView1.FindEditFormTemplateControl("txt_Name") as ASPxTextBox;
        string      name    = txtName.Text.Trim();

        if (txtName.Text == "")
        {
            throw new Exception("Full Name not be null!!!");
        }
        product.Name = name;
        ASPxButtonEdit txt_PartyId = ASPxGridView1.FindEditFormTemplateControl("btnParty") as ASPxButtonEdit;

        product.PartyId = txt_PartyId.Text;
        ASPxComboBox cbProductClass = ASPxGridView1.FindEditFormTemplateControl("cbProductClass") as ASPxComboBox;

        product.ProductClass = cbProductClass.Text.Trim();
        //ASPxComboBox cbCountry = grid.FindEditFormTemplateControl("cbCountry") as ASPxComboBox;
        //product.Country= cbCountry.Text;
        ASPxTextBox txt_BrandName = ASPxGridView1.FindEditFormTemplateControl("txt_BrandName") as ASPxTextBox;

        product.BrandName = txt_BrandName.Text;
        ASPxSpinEdit txt_QtyPackingWhole = ASPxGridView1.FindEditFormTemplateControl("txt_QtyPackingWhole") as ASPxSpinEdit;

        product.QtyPackingWhole = SafeValue.SafeInt(txt_QtyPackingWhole.Text, 0);
        ASPxMemo txt_Description = ASPxGridView1.FindEditFormTemplateControl("txt_Description") as ASPxMemo;

        product.Description = txt_Description.Text;
        ASPxSpinEdit txt_QtyWholeLoose = ASPxGridView1.FindEditFormTemplateControl("txt_QtyWholeLoose") as ASPxSpinEdit;

        product.QtyWholeLoose = SafeValue.SafeInt(txt_QtyWholeLoose.Text, 0);
        ASPxSpinEdit spin_LengthPacking = ASPxGridView1.FindEditFormTemplateControl("spin_LengthPacking") as ASPxSpinEdit;

        product.LengthPacking = SafeValue.SafeDecimal(spin_LengthPacking.Text);
        ASPxSpinEdit spin_WidthPacking = ASPxGridView1.FindEditFormTemplateControl("spin_WidthPacking") as ASPxSpinEdit;

        product.WidthPacking = SafeValue.SafeDecimal(spin_WidthPacking.Text);
        ASPxSpinEdit spin_HeightPacking = ASPxGridView1.FindEditFormTemplateControl("spin_HeightPacking") as ASPxSpinEdit;

        product.HeightPacking = SafeValue.SafeDecimal(spin_HeightPacking.Text);
        ASPxSpinEdit spin_VolumePacking = ASPxGridView1.FindEditFormTemplateControl("spin_VolumePacking") as ASPxSpinEdit;

        product.VolumePacking = SafeValue.SafeDecimal(spin_VolumePacking.Text);
        ASPxButtonEdit spin_UomPacking = ASPxGridView1.FindEditFormTemplateControl("spin_UomPacking") as ASPxButtonEdit;

        product.UomPacking = spin_UomPacking.Text;
        ASPxSpinEdit spin_LengthWhole = ASPxGridView1.FindEditFormTemplateControl("spin_LengthWhole") as ASPxSpinEdit;

        product.LengthWhole = SafeValue.SafeDecimal(spin_LengthWhole.Text);
        ASPxSpinEdit spin_WidthWhole = ASPxGridView1.FindEditFormTemplateControl("spin_WidthWhole") as ASPxSpinEdit;

        product.WidthWhole = SafeValue.SafeDecimal(spin_WidthWhole.Text);
        ASPxSpinEdit spin_HeightWhole = ASPxGridView1.FindEditFormTemplateControl("spin_HeightWhole") as ASPxSpinEdit;

        product.HeightWhole = SafeValue.SafeDecimal(spin_HeightWhole.Text);
        ASPxSpinEdit spin_VolumeWhole = ASPxGridView1.FindEditFormTemplateControl("spin_VolumeWhole") as ASPxSpinEdit;

        product.VolumeWhole = SafeValue.SafeDecimal(spin_VolumeWhole.Text);
        ASPxButtonEdit spin_UomWhole = ASPxGridView1.FindEditFormTemplateControl("spin_UomWhole") as ASPxButtonEdit;

        product.UomWhole = spin_UomWhole.Text;
        ASPxSpinEdit spin_VolumeLoose = ASPxGridView1.FindEditFormTemplateControl("spin_VolumeLoose") as ASPxSpinEdit;

        product.VolumeLoose = SafeValue.SafeDecimal(spin_VolumeLoose.Text);
        ASPxSpinEdit spin_LengthLoose = ASPxGridView1.FindEditFormTemplateControl("spin_LengthLoose") as ASPxSpinEdit;

        product.LengthLoose = SafeValue.SafeDecimal(spin_LengthLoose.Text);
        ASPxSpinEdit spin_WidthLoose = ASPxGridView1.FindEditFormTemplateControl("spin_WidthLoose") as ASPxSpinEdit;

        product.WidthLoose = SafeValue.SafeDecimal(spin_WidthLoose.Text);
        ASPxSpinEdit spin_HeightLoose = ASPxGridView1.FindEditFormTemplateControl("spin_HeightLoose") as ASPxSpinEdit;

        product.HeightLoose = SafeValue.SafeDecimal(spin_HeightLoose.Text);
        ASPxButtonEdit spin_UomLoose = ASPxGridView1.FindEditFormTemplateControl("spin_UomLoose") as ASPxButtonEdit;

        product.UomLoose = spin_UomLoose.Text;
        ASPxSpinEdit spin_CostPrice = ASPxGridView1.FindEditFormTemplateControl("spin_CostPrice") as ASPxSpinEdit;

        product.CostPrice = SafeValue.SafeDecimal(spin_CostPrice.Text);
        ASPxSpinEdit spin_Saleprice = ASPxGridView1.FindEditFormTemplateControl("spin_Saleprice") as ASPxSpinEdit;

        product.Saleprice = SafeValue.SafeDecimal(spin_Saleprice.Text);
        product.CreateBy  = HttpContext.Current.User.Identity.Name;
        ASPxTextBox hsCode = ASPxGridView1.FindEditFormTemplateControl("txt_HsCode") as ASPxTextBox;

        product.HsCode = hsCode.Text;
        ASPxSpinEdit QtyLooseBase = ASPxGridView1.FindEditFormTemplateControl("txt_QtyLooseBase") as ASPxSpinEdit;

        product.QtyLooseBase = SafeValue.SafeInt(QtyLooseBase.Text, 0);

        ASPxButtonEdit txt_UomBase = ASPxGridView1.FindEditFormTemplateControl("txt_UomBase") as ASPxButtonEdit;

        product.UomBase        = txt_UomBase.Text;
        product.CreateDateTime = DateTime.Now;

        ASPxComboBox cb_Att1 = ASPxGridView1.FindEditFormTemplateControl("cb_Att1") as ASPxComboBox;

        product.Att4 = SafeValue.SafeString(cb_Att1.Text);
        ASPxComboBox cb_Att2 = ASPxGridView1.FindEditFormTemplateControl("cb_Att2") as ASPxComboBox;

        product.Att5 = SafeValue.SafeString(cb_Att2.Text);
        ASPxComboBox cb_Att3 = ASPxGridView1.FindEditFormTemplateControl("cb_Att3") as ASPxComboBox;

        product.Att6 = SafeValue.SafeString(cb_Att3.Text);
        ASPxComboBox cb_Att4 = ASPxGridView1.FindEditFormTemplateControl("cb_Att4") as ASPxComboBox;

        product.Att7 = SafeValue.SafeString(cb_Att4.Text);
        ASPxComboBox cb_Att5 = ASPxGridView1.FindEditFormTemplateControl("cb_Att5") as ASPxComboBox;

        product.Att8 = SafeValue.SafeString(cb_Att5.Text);
        ASPxComboBox cb_Att6 = ASPxGridView1.FindEditFormTemplateControl("cb_Att6") as ASPxComboBox;

        product.Att9 = SafeValue.SafeString(cb_Att6.Text);
        ASPxTextBox txt_ArCode = ASPxGridView1.FindEditFormTemplateControl("txt_ArCode") as ASPxTextBox;

        product.ArCode = SafeValue.SafeString(txt_ArCode.Text.Trim());
        ASPxTextBox txt_ApCode = ASPxGridView1.FindEditFormTemplateControl("txt_ApCode") as ASPxTextBox;

        product.ApCode = SafeValue.SafeString(txt_ApCode.Text.Trim());
        if (txt_ArCode.Text.Trim() == "")
        {
            product.ArCode = System.Configuration.ConfigurationManager.AppSettings["ItemArCode"];
        }
        if (txt_ApCode.Text.Trim() == "")
        {
            product.ApCode = System.Configuration.ConfigurationManager.AppSettings["ItemApCode"];
        }
        ASPxSpinEdit MinOrderQty = ASPxGridView1.FindEditFormTemplateControl("spin_MinOrderQty") as ASPxSpinEdit;

        product.MinOrderQty = SafeValue.SafeInt(MinOrderQty.Text, 0);
        ASPxSpinEdit NewOrderQty = ASPxGridView1.FindEditFormTemplateControl("spin_NewOrderQty") as ASPxSpinEdit;

        product.NewOrderQty = SafeValue.SafeInt(NewOrderQty.Text, 0);
        //ASPxComboBox cb_Att7 = grid.FindEditFormTemplateControl("cb_Att7") as ASPxComboBox;
        //product.Att10 = SafeValue.SafeString(cb_Att7.Text);
        //ASPxComboBox cb_Att8 = grid.FindEditFormTemplateControl("cb_Att8") as ASPxComboBox;
        //product.Att11 = SafeValue.SafeString(cb_Att8.Text);
        //ASPxComboBox cb_Att9 = grid.FindEditFormTemplateControl("cb_Att9") as ASPxComboBox;
        //product.Att12 = SafeValue.SafeString(cb_Att9.Text);
        //ASPxComboBox cb_Att10 = grid.FindEditFormTemplateControl("cb_Att10") as ASPxComboBox;
        //product.Att13 = SafeValue.SafeString(cb_Att10.Text);
        product.Att1 = "1" + product.UomPacking;
        if (product.QtyPackingWhole > 0 && product.UomWhole.Length > 0)
        {
            product.Att1 += string.Format("x{0}{1}", product.QtyPackingWhole, product.UomWhole);
        }
        if (product.QtyWholeLoose > 0 && product.UomLoose.Length > 0)
        {
            product.Att1 += string.Format("x{0}{1}", product.QtyWholeLoose, product.UomLoose);
        }
        if (product.QtyLooseBase > 0 && product.UomBase.Length > 0)
        {
            product.Att1 += string.Format("x{0}{1}", product.QtyLooseBase, product.UomBase);
        }

        ASPxComboBox cmb_OptionType = ASPxGridView1.FindEditFormTemplateControl("cmb_OptionType") as ASPxComboBox;

        product.OptionType = SafeValue.SafeString(cmb_OptionType.Value);
        product.Att4       = SafeValue.SafeString(cb_Att1.Text);

        if (txt_UomBase.Text == "Packing")
        {
            product.Att3 = spin_UomPacking.Text;
        }
        else if (txt_UomBase.Text == "Whole")
        {
            product.Att3 = spin_UomWhole.Text;
        }
        else
        {
            product.Att3 = spin_UomLoose.Text;
        }
        if (cbProductClass.Text == "CIGR")
        {
            product.UomPacking = "PKG";
            product.UomWhole   = "BOX";
            product.UomLoose   = "PKT";
            product.UomBase    = "STK";
        }
        if (action)
        {
            product.StatusCode     = "USE";
            product.CreateBy       = EzshipHelper.GetUserName();
            product.CreateDateTime = DateTime.Now;
            Manager.ORManager.StartTracking(product, Wilson.ORMapper.InitialState.Inserted);
            Manager.ORManager.PersistChanges(product);
            txt_pId.Text = product.Id.ToString();
            C2Setup.SetNextNo("", "Product", code, DateTime.Now);
        }
        else
        {
            product.UpdateBy       = EzshipHelper.GetUserName();
            product.UpdateDateTime = DateTime.Now;
            Manager.ORManager.StartTracking(product, Wilson.ORMapper.InitialState.Updated);
            Manager.ORManager.PersistChanges(product);
        }
        Session["ProductWhere"]         = "Code='" + product.Code + "'";
        this.dsProduct.FilterExpression = Session["ProductWhere"].ToString();
        if (this.ASPxGridView1.GetRow(0) != null)
        {
            this.ASPxGridView1.StartEdit(0);
        }
    }
Beispiel #51
0
    public static void SetDDLPerType(ASPxComboBox ddl)
    {
        try
        {
            //string sql = "select PER_TYPE,PER_TYPE_NAME from PSST_PER_TYPE where ORDER_SEQ is not null order by PER_TYPE";
            string sql = " SELECT SP.PER_TYPE ,PT.PER_TYPE_NAME"+Environment.NewLine;
            sql += " FROM SMM_PER_TYPE SP"+Environment.NewLine;
            sql += " INNER JOIN PSST_PER_TYPE PT ON SP.PER_TYPE=PT.PER_TYPE"+Environment.NewLine;
            SqlDataAdapter da = new SqlDataAdapter(sql, StaticDefaultConnectionString);
            DataTable dt = new DataTable();
            da.Fill(dt);
            if (dt.Rows.Count > 0)
            {
                ddl.ValueField = "PER_TYPE";
                ddl.TextField = "PER_TYPE_NAME";

                ddl.DataSource = dt;
                ddl.DataBind();
            }
        }
        catch (Exception ex)
        {

        }
    }
Beispiel #52
0
    protected void grid_CustomDataCallback(object sender, DevExpress.Web.ASPxGridView.ASPxGridViewCustomDataCallbackEventArgs e)
    {
        if (Request.QueryString["wh"] != null && Request.QueryString["no"] != null)
        {
            int start = 0;     //
            int end   = 10000; //
            int qty   = 0;
            for (int a = start; a < end; a++)
            {
                string       sql    = "";
                ASPxTextBox  txt_Id = this.grid.FindRowTemplateControl(a, "txt_Id") as ASPxTextBox;
                ASPxCheckBox isPay  = this.grid.FindRowTemplateControl(a, "ack_IsPay") as ASPxCheckBox;
                if (isPay != null && isPay.Checked)
                {
                    int    invId = SafeValue.SafeInt(Request.QueryString["id"], 0);
                    string no    = SafeValue.SafeString(Request.QueryString["no"]);
                    string s     = e.Parameters;
                    if (s == "OK")
                    {
                        #region SO Det

                        try
                        {
                            sql = string.Format("select Id,Code from ref_product where Id={0}", SafeValue.SafeInt(txt_Id.Text, 0));
                            DataTable tab = ConnectSql.GetTab(sql);
                            WhSoDet   det = null;
                            for (int i = 0; i < tab.Rows.Count; i++)
                            {
                                string       product      = tab.Rows[i]["Code"].ToString();
                                ASPxSpinEdit spin_Qty     = this.grid.FindRowTemplateControl(a, "spin_Qty") as ASPxSpinEdit;
                                ASPxSpinEdit spin_Price   = this.grid.FindRowTemplateControl(a, "spin_Price") as ASPxSpinEdit;
                                ASPxSpinEdit spin_ExRate  = this.grid.FindRowTemplateControl(a, "spin_ExRate") as ASPxSpinEdit;
                                ASPxSpinEdit spin_GstP    = this.grid.FindRowTemplateControl(a, "spin_GstP") as ASPxSpinEdit;
                                ASPxTextBox  txt_Currency = this.grid.FindRowTemplateControl(a, "txt_Currency") as ASPxTextBox;
                                ASPxComboBox cmb_GstType  = this.grid.FindRowTemplateControl(a, "cmb_GstType") as ASPxComboBox;
                                decimal      price        = SafeValue.SafeDecimal(spin_Price.Value, 0);
                                string       currency     = SafeValue.SafeString(txt_Currency.Text);
                                decimal      exRate       = SafeValue.SafeDecimal(spin_ExRate.Value, 0);
                                decimal      gst          = SafeValue.SafeDecimal(spin_GstP.Value, 0);
                                string       gstType      = SafeValue.SafeString(cmb_GstType.Text);
                                qty          = SafeValue.SafeInt(spin_Qty.Value, 0);
                                det          = new WhSoDet();
                                det.Product  = product;
                                det.Currency = currency;
                                det.ExRate   = exRate;
                                det.Price    = price;
                                det.Qty      = qty;
                                det.SoNo     = no;
                                det.Gst      = gst;
                                det.BalQty   = qty;
                                det.GstType  = gstType;
                                if (gstType == "S")
                                {
                                    gst = SafeValue.SafeDecimal(0.07, 0);
                                }
                                decimal amt    = SafeValue.ChinaRound(qty * price, 2);
                                decimal gstAmt = SafeValue.ChinaRound(amt * gst, 2);
                                decimal docAmt = amt + gstAmt;
                                decimal locAmt = SafeValue.ChinaRound(docAmt * exRate, 2);
                                det.GstAmt = gstAmt;
                                det.DocAmt = docAmt;
                                det.LocAmt = locAmt;
                                C2.Manager.ORManager.StartTracking(det, Wilson.ORMapper.InitialState.Inserted);
                                C2.Manager.ORManager.PersistChanges(det);
                            }
                        }
                        catch (Exception ex)
                        {
                        }
                        #endregion
                    }
                }
            }
        }
        else
        {
            e.Result = "Error, Pls refresh your Det";
        }
    }
Beispiel #53
0
    public static void SetDDLPosition(ASPxComboBox ddl)
    {
        try
        {
            string sql = "select POS_ID,POS_NAME + '(' + POS_ID + ')' POS_NAME from vw_CMN_POSITION ";
            SqlDataAdapter da = new SqlDataAdapter(sql, StaticDefaultConnectionString);
            DataTable dt = new DataTable();
            da.Fill(dt);
            if (dt.Rows.Count > 0)
            {
                ddl.ValueField = "POS_ID";
                ddl.TextField = "POS_NAME";

                ddl.DataSource = dt;
                ddl.DataBind();

                ddl.SelectedIndex = 0;
            }
        }
        catch (Exception ex)
        {

        }
    }
Beispiel #54
0
    private void Save()
    {
        try
        {
            ASPxPageControl            pageControl = this.grid_WhPoR.FindEditFormTemplateControl("pageControl") as ASPxPageControl;
            ASPxTextBox                txtId       = pageControl.FindControl("txt_Id") as ASPxTextBox;
            string                     id          = SafeValue.SafeString(txtId.Text, "");
            Wilson.ORMapper.OPathQuery query       = new Wilson.ORMapper.OPathQuery(typeof(WhPOReceipt), "Id='" + id + "'");
            WhPOReceipt                whPOR       = C2.Manager.ORManager.GetObject(query) as WhPOReceipt;
            bool   isNew = false;
            string porNo = "";
            if (whPOR == null)
            {
                whPOR = new WhPOReceipt();
                isNew = true;
                porNo = C2Setup.GetNextNo("PurchaseOrdersReceipt");
            }
            ASPxTextBox txt_PartyRefNo = pageControl.FindControl("txt_PartyRefNo") as ASPxTextBox;
            whPOR.PartyRefNo = txt_PartyRefNo.Text;
            ASPxButtonEdit txt_PartyId = pageControl.FindControl("txt_PartyId") as ASPxButtonEdit;
            whPOR.PartyId = txt_PartyId.Text;
            ASPxDateEdit de_ReceiptDate = pageControl.FindControl("de_ReceiptDate") as ASPxDateEdit;
            whPOR.ReceiptDate = de_ReceiptDate.Date;
            ASPxComboBox cbo_ReceiptType = pageControl.FindControl("cbo_ReceiptType") as ASPxComboBox;
            whPOR.ReceiptType = SafeValue.SafeString(cbo_ReceiptType.Value);
            ASPxButtonEdit txt_WarehouseId = pageControl.FindControl("txt_WarehouseId") as ASPxButtonEdit;
            whPOR.WarehouseId = txt_WarehouseId.Text;
            ASPxButtonEdit txt_SalesmanId = pageControl.FindControl("txt_SalesmanId") as ASPxButtonEdit;
            whPOR.SalesmanId = txt_SalesmanId.Text;
            ASPxButtonEdit txt_Currency = pageControl.FindControl("txt_Currency") as ASPxButtonEdit;
            whPOR.Currency = txt_Currency.Text;
            ASPxSpinEdit spin_ExRate = pageControl.FindControl("spin_ExRate") as ASPxSpinEdit;
            whPOR.ExRate = SafeValue.SafeDecimal(spin_ExRate.Value, 1);
            ASPxMemo txt_Remark = pageControl.FindControl("txt_Remark") as ASPxMemo;
            whPOR.Remark = txt_Remark.Text;

            string userId = HttpContext.Current.User.Identity.Name;
            if (isNew)
            {
                whPOR.CreateBy       = userId;
                whPOR.CreateDateTime = DateTime.Now;
                whPOR.ReceiptNo      = porNo.ToString();
                whPOR.StatusCode     = "USE";
                Manager.ORManager.StartTracking(whPOR, Wilson.ORMapper.InitialState.Inserted);
                Manager.ORManager.PersistChanges(whPOR);
                C2Setup.SetNextNo("PurchaseOrdersReceipt", porNo);
            }
            else
            {
                whPOR.UpdateBy       = userId;
                whPOR.UpdateDateTime = DateTime.Now;
                Manager.ORManager.StartTracking(whPOR, Wilson.ORMapper.InitialState.Updated);
                Manager.ORManager.PersistChanges(whPOR);
            }
            Session["PORWhere"] = "ReceiptNo='" + whPOR.ReceiptNo + "'";
            this.dsWhPOReceipt.FilterExpression = Session["PORWhere"].ToString();
            if (this.grid_WhPoR.GetRow(0) != null)
            {
                this.grid_WhPoR.StartEdit(0);
            }
        }
        catch { }
    }
Beispiel #55
0
    public static void Set_DDLORG_LV1_2(ASPxComboBox ddl)
    {
        try
        {
            string sql = "select * from (select 'A' as Group1 , ORG_SERIAL,ORG_NAME,ORG_ABBR from vw_SMM_ORG_LEVEL1 union " + Environment.NewLine;
            sql += "select 'B' as Group1 ,ORG_SERIAL,ORG_NAME,ORG_ABBR from vw_SMM_ORG_LEVEL2 ) as TB where 1=1" + Environment.NewLine;
            sql += "order by Group1,ORG_SERIAL";
            SqlDataAdapter da = new SqlDataAdapter(sql, StaticDefaultConnectionString);
            DataTable dt = new DataTable();
            da.Fill(dt);

            if (dt.Rows.Count > 0)
            {
                ddl.Columns.Clear();

                ddl.ValueField = "ORG_SERIAL";
                ddl.TextField = "ORG_NAME";

                ddl.DataSource = dt;
                ddl.DataBind();
            }
        }
        catch (Exception ex)
        {

        }
    }
Beispiel #56
0
        protected void gridScorecard_BeforePerformDataSelect(object sender, EventArgs e)
        {
            ASPxPageControl pc            = gridArea.FindControl("ASPxPageControlArea") as ASPxPageControl;
            ASPxComboBox    cb            = gridArea.FindDetailRowTemplateControl(3, "ddlScorecard") as ASPxComboBox;
            ASPxGridView    gridScorecard = (ASPxGridView)sender;


            String ItemKey = Session["ItemKey"].ToString();

            Guid projectID = Guid.Parse(Session["projectID"].ToString());


            if (CurrentCard != null)
            {
                //Bind Grid

                gridScorecard.DataSource = rc_services.GetScores((String)Session["ProjectID"], ItemKey, ScorecardKey);

                //Get ScoreCard Info

                //Prep the COlumns
                //Get the Score COlumns
                GridViewColumn Score1 = gridScorecard.Columns["ScoreCol1"];
                GridViewColumn Score2 = gridScorecard.Columns["ScoreCol2"];
                GridViewColumn Score3 = gridScorecard.Columns["ScoreCol3"];
                GridViewColumn Score4 = gridScorecard.Columns["ScoreCol4"];
                GridViewColumn Score5 = gridScorecard.Columns["ScoreCol5"];

                ////now check which score columns are enabled, and set their visibility
                Score1.Visible = CurrentCard.EnabledCol1; //ComboHeader1.Visible = Col1Visible;
                Score2.Visible = CurrentCard.EnabledCol2; //ComboHeader2.Visible = Col2Visible;
                Score3.Visible = CurrentCard.EnabledCol3; //ComboHeader3.Visible = Col3Visible;
                Score4.Visible = CurrentCard.EnabledCol4; //ComboHeader4.Visible = Col4Visible;
                Score5.Visible = CurrentCard.EnabledCol5; //ComboHeader5.Visible = Col5Visible;


                ////Set Their captions
                Score1.Caption = CurrentCard.CardCol1;
                Score2.Caption = CurrentCard.CardCol2;
                Score3.Caption = CurrentCard.CardCol3;
                Score4.Caption = CurrentCard.CardCol4;
                Score5.Caption = CurrentCard.CardCol5;

                ////Check if measure are enabled, if so, set their visibility and captions (if that score column is visible)

                ////Get Measure Columns
                GridViewColumn Measure1 = gridScorecard.Columns["Measure1"];
                GridViewColumn Measure2 = gridScorecard.Columns["Measure2"];
                GridViewColumn Measure3 = gridScorecard.Columns["Measure3"];
                GridViewColumn Measure4 = gridScorecard.Columns["Measure4"];
                GridViewColumn Measure5 = gridScorecard.Columns["Measure5"];

                if (CurrentCard.MeasuredEnabled == true)
                {
                    Measure1.Visible = CurrentCard.EnabledCol1;
                    Measure2.Visible = CurrentCard.EnabledCol2;
                    Measure3.Visible = CurrentCard.EnabledCol3;
                    Measure4.Visible = CurrentCard.EnabledCol4;
                    Measure5.Visible = CurrentCard.EnabledCol5;
                }
                else
                {
                    Measure1.Visible = false;
                    Measure2.Visible = false;
                    Measure3.Visible = false;
                    Measure4.Visible = false;
                    Measure5.Visible = false;
                }
            }
        }
 protected override System.Web.UI.WebControls.WebControl CreateEditModeControlCore() {
     _control = CreateDurationEditor();
     _control.ValueChanged += EditValueChangedHandler;
     return _control;
 }
Beispiel #58
0
    }//end menu names loop

    #endregion

    #region company crud operations
    protected void fmvAddressBook_ItemInserting(object sender, FormViewInsertEventArgs e)
    {
        int _user    = Page.Session["user"] != null ? (int)((UserClass)Page.Session["user"]).UserId : 0;
        int?_intnull = null;
        //this.objdsAddressBook.InsertParameters["DateRecordAdded"].DefaultValue = DateTime.Now.ToShortDateString();
        //this.objdsAddressBook.InsertParameters["RecordAddedBY"].DefaultValue = _username;
        FormView _f = (FormView)this.FindControl("fmvAddressBook");

        if (_f != null)
        {
            NameAndAddressBook _n = new NameAndAddressBook();
            _n.DateRecordAdded = DateTime.Now;
            _n.RecordAddedBY   = _user;

            ASPxTextBox _tx = (ASPxTextBox)_f.FindControl("dxtxtname");
            if (_tx != null)
            {
                _n.CompanyName = _tx.Text != null?_tx.Text.ToString() : "";
            }

            _tx = (ASPxTextBox)_f.FindControl("dxtxtAddress1");
            if (_tx != null)
            {
                _n.Address1 = _tx.Text != null?_tx.Text.ToString() : "";
            }

            _tx = (ASPxTextBox)_f.FindControl("dxtxtAddress2");
            if (_tx != null)
            {
                _n.Address2 = _tx.Text != null?_tx.Text.ToString() : "";
            }

            _tx = (ASPxTextBox)_f.FindControl("dxtxtAddress3");
            if (_tx != null)
            {
                _n.Address3 = _tx.Text != null?_tx.Text.ToString() : "";
            }

            ASPxComboBox _cb = (ASPxComboBox)_f.FindControl("dxcboCountry");
            if (_cb != null)
            {
                _n.CountryID = _cb.Value != null?wwi_func.vint(_cb.Value.ToString()) : _intnull;
            }

            _tx = (ASPxTextBox)_f.FindControl("dxtxtPostCode");
            if (_tx != null)
            {
                _n.PostCode = _tx.Text != null?_tx.Text.ToString() : "";
            }

            _tx = (ASPxTextBox)_f.FindControl("dxtxtTelNo");
            if (_tx != null)
            {
                _n.TelNo = _tx.Text != null?_tx.Text.ToString() : "";
            }

            _tx = (ASPxTextBox)_f.FindControl("dxtxtFax");
            if (_tx != null)
            {
                _n.FaxNo = _tx.Text != null?_tx.Text.ToString() : "";
            }

            _tx = (ASPxTextBox)_f.FindControl("dxtxtEmail");
            if (_tx != null)
            {
                _n.MainEmail = _tx.Text != null?_tx.Text.ToString() : "";
            }

            _cb = (ASPxComboBox)_f.FindControl("dxcboCompanyType");
            if (_cb != null)
            {
                _n.TypeID = _cb.Value != null?wwi_func.vint(_cb.Value.ToString()) : _intnull;
            }

            ASPxMemo _m = (ASPxMemo)_f.FindControl("dxmemoDelivery");
            if (_m != null)
            {
                _n.SpecialDeliveryInstructions = _m.Text != null?_m.Text.ToString() : "";
            }

            _tx = (ASPxTextBox)_f.FindControl("dxtxtPalletSpec");
            if (_tx != null)
            {
                _n.PalletDims = _tx.Text != null?_tx.Text.ToString() : "";
            }

            _tx = (ASPxTextBox)_f.FindControl("dxtxtMaxWeight"); //check for nullable int
            if (_tx != null)
            {
                int?_v = 0;
                if (!string.IsNullOrEmpty(_tx.Text.ToString()))
                {
                    _v = wwi_func.vint(_tx.Text.ToString());
                }
                _n.MaxPalletWeight = _v.Value;
            }

            _tx = (ASPxTextBox)_f.FindControl("dxtxtMaxHeight"); //check for nullable int
            if (_tx != null)
            {
                int?_v = 0;
                if (!string.IsNullOrEmpty(_tx.Text.ToString()))
                {
                    _v = wwi_func.vint(_tx.Text.ToString());
                }
                _n.MaxPalletHeight = _v.Value;
            }

            ASPxCheckBox _ck = (ASPxCheckBox)_f.FindControl("dxckExporter");
            if (_ck != null)
            {
                _n.Exporter = _ck.Checked;
            }

            _ck = (ASPxCheckBox)_f.FindControl("dxckCustomer");
            if (_ck != null)
            {
                _n.Customer = _ck.Checked;
            }

            _ck = (ASPxCheckBox)_f.FindControl("dxckConsignee");
            if (_ck != null)
            {
                _n.Consignee = _ck.Checked;
            }

            _ck = (ASPxCheckBox)_f.FindControl("dxckInsurance");
            if (_ck != null)
            {
                _n.Insurance = _ck.Checked;
            }

            _ck = (ASPxCheckBox)_f.FindControl("dxckSalesTarget");
            if (_ck != null)
            {
                _n.SalesModule = _ck.Checked;
            }

            _n.Save();
            //return new company id
            int _newid = (Int32)_n.GetPrimaryKeyValue();
            //add to hidden field as we won't be able to retrive this from page request
            if (this.dxhfOrder.Contains("pid"))
            {
                this.dxhfOrder.Remove("pid");
            }
            this.dxhfOrder.Add("pid", _newid);
            ///update id label
            ASPxLabel _lb = (ASPxLabel)_f.FindControl("dxlblCompanyID");
            if (_lb != null)
            {
                _lb.Text = _newid.ToString();
            }
        }
    }
 protected void CheckValue(ASPxComboBox a)
 {
     string Str = a.Text.Trim();
     double Num;
     bool isNum = double.TryParse(Str, out Num);
     if (isNum)
     {
         GenerateScript("alert('OK')");
     }
     else GenerateScript("alert('Fail')"); ;
 }
Beispiel #60
0
    //end formview inserting
    /// <summary>
    /// by binding in code behind we can avoid objectdatasource not updating nullable values correctly
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void fmvAddressBook_ItemUpdating(object sender, FormViewUpdateEventArgs e)
    {
        int _id      = wwi_func.vint(get_token("pid"));
        int?_intnull = null;

        if (_id > 0)
        {
            FormView _f = (FormView)this.FindControl("fmvAddressBook");
            if (_f != null)
            {
                //ASPxLabel _lb = (ASPxLabel)_f.FindControl("dxlblCompanyID");
                //if (_lb != null) { _id = _lb.Text.ToString(); }

                NameAndAddressBook _n = new NameAndAddressBook(_id);

                ASPxTextBox _tx = (ASPxTextBox)_f.FindControl("dxtxtName");
                if (_tx != null)
                {
                    _n.CompanyName = _tx.Text != null?_tx.Text.ToString() : "";
                }

                _tx = (ASPxTextBox)_f.FindControl("dxtxtAddress1");
                if (_tx != null)
                {
                    _n.Address1 = _tx.Text != null?_tx.Text.ToString() : "";
                }

                _tx = (ASPxTextBox)_f.FindControl("dxtxtAddress2");
                if (_tx != null)
                {
                    _n.Address2 = _tx.Text != null?_tx.Text.ToString() : "";
                }

                _tx = (ASPxTextBox)_f.FindControl("dxtxtAddress3");
                if (_tx != null)
                {
                    _n.Address3 = _tx.Text != null?_tx.Text.ToString() : "";
                }

                ASPxComboBox _cb = (ASPxComboBox)_f.FindControl("dxcboCountry");
                if (_cb != null)
                {
                    _n.CountryID = wwi_func.vint(_cb.Value.ToString());
                }

                _tx = (ASPxTextBox)_f.FindControl("dxtxtPostCode");
                if (_tx != null)
                {
                    _n.PostCode = _tx.Text != null?_tx.Text.ToString() : "";
                }

                _tx = (ASPxTextBox)_f.FindControl("dxtxtTelNo");
                if (_tx != null)
                {
                    _n.TelNo = _tx.Text != null?_tx.Text.ToString() : "";
                }

                _tx = (ASPxTextBox)_f.FindControl("dxtxtFax");
                if (_tx != null)
                {
                    _n.FaxNo = _tx.Text != null?_tx.Text.ToString() : "";
                }

                _tx = (ASPxTextBox)_f.FindControl("dxtxtEmail");
                if (_tx != null)
                {
                    _n.MainEmail = _tx.Text != null?_tx.Text.ToString() : "";
                }

                _cb = (ASPxComboBox)_f.FindControl("dxcboCompanyType");
                if (_cb != null)
                {
                    _n.TypeID = _cb.Value != null?wwi_func.vint(_cb.Value.ToString()) : _intnull;
                }

                ASPxMemo _m = (ASPxMemo)_f.FindControl("dxmemoDelivery");
                if (_m != null)
                {
                    _n.SpecialDeliveryInstructions = _m.Text != null?_m.Text.ToString() : "";
                }

                _tx = (ASPxTextBox)_f.FindControl("dxtxtPalletSpec");
                if (_tx != null)
                {
                    _n.PalletDims = _tx.Text != null?_tx.Text.ToString() : "";
                }

                _tx = (ASPxTextBox)_f.FindControl("dxtxtMaxWeight"); //check for nullable int
                if (_tx != null)
                {
                    int?_v = 0;
                    if (!string.IsNullOrEmpty(_tx.Text.ToString()))
                    {
                        _v = wwi_func.vint(_tx.Text.ToString());
                    }
                    _n.MaxPalletWeight = _v;
                }

                _tx = (ASPxTextBox)_f.FindControl("dxtxtMaxHeight"); //check for nullable int
                if (_tx != null)
                {
                    int?_v = 0;
                    if (!string.IsNullOrEmpty(_tx.Text.ToString()))
                    {
                        _v = wwi_func.vint(_tx.Text.ToString());
                    }
                    _n.MaxPalletHeight = _v;
                }

                ASPxCheckBox _ck = (ASPxCheckBox)_f.FindControl("dxckExporter");
                if (_ck != null)
                {
                    _n.Exporter = _ck.Checked;
                }

                _ck = (ASPxCheckBox)_f.FindControl("dxckCustomer");
                if (_ck != null)
                {
                    _n.Customer = _ck.Checked;
                }

                _ck = (ASPxCheckBox)_f.FindControl("dxckConsignee");
                if (_ck != null)
                {
                    _n.Consignee = _ck.Checked;
                }

                _ck = (ASPxCheckBox)_f.FindControl("dxckInsurance");
                if (_ck != null)
                {
                    _n.Insurance = _ck.Checked;
                }

                _ck = (ASPxCheckBox)_f.FindControl("dxckSalesTarget");
                if (_ck != null)
                {
                    _n.SalesModule = _ck.Checked;
                }

                _n.Save();
            }
            //end formview updating
        }
    }